PDA

Просмотр полной версии : Длинна ассоциативного массива, КАК ?


netstuff
06.08.2002, 12:28
не могу понять, как бы мне извлечь количество элементов ассоциативного массива :(

lexass
06.08.2002, 12:54
.length

netstuff
06.08.2002, 13:00
не катит :(

Property; contains the length of the array. This property is automatically updated when new elements are added to the array. When you assign a value to an array element (for example, myArray[index] = value), if index is a number, and index+1 is a greater than the length property, the length property is updated to index + 1.

Что же мне делать?

ish
06.08.2002, 13:37
Object.prototype.addProperty("__length__", function () {
var count = 0;
for (var i in this) {
count++;
}
return count;
}, null);
ASSetPropFlags(Object.prototype,"__length__",7,1)


obj = new Object();
obj.a = 1;
obj.b = 2;
obj.c = 3;
trace(obj.__length__) // 3

netstuff
06.08.2002, 16:23
2 ishASSetPropFlags(Object.prototype,"__length__",7,1)

чего за функция? недокументированная?

netstuff
06.08.2002, 16:39
благодаря твоему коду нашел замес:

было:

for(var i=0; i<element.attributes.length; i++) {....

стало:

for(var i in element.attributes) {

работает

greep
06.08.2002, 21:29
netstuff,
а пришли исходник ???