Показать сообщение отдельно
Старый 14.05.2004, 23:56
realMakc вне форума Посмотреть профиль Отправить личное сообщение для realMakc Найти все сообщения от realMakc
  № 1  
realMakc
 
Аватар для realMakc

Регистрация: Oct 2002
Сообщений: 284
Отправить сообщение для realMakc с помощью ICQ
По умолчанию опять фигня с ядрёными объектами

Переводить не буду, люди тут грамотные
Код:
<BODY>
  This script worx as expected in both Mozilla and Opera, but not in IE :(
  You can see that "push" method of "Array" class is inherited in "MyArray",
  but "length" property appear to be "missing" in such a strange way, that
  attempt to retrieve its value always returns zero (not "null", but 0),
  which is the reason why anything we are trying to push actually goes to
  a[0]. This is not really "ECMA compatible", I think...
</BODY>
<SCRiPT>

MyArray = function () {}
MyArray.prototype = new Array ()
MyArray.prototype.f = function ()
{
 this.length = 1
	alert(this.length) // expected 1, alerts 0
 this.push("a")
 this.push("b")
	alert(this.length) // expected 3, alerts 0
}

a = new MyArray (); a.f () // run above tests

alert(a[1]) // expected a, alerts undefined
alert(a[2]) // expected b, alerts undefined

alert(a[0]) // expected undefined, alerts b

</SCRiPT>