This is a newbie question, but I learn a lot every time I ask.
Why do some objects return a zero length?
I'm doing Array.each. In the array at this particular time is a
single object. Firebug describes that object as
Object Brainwriting color=black penwidth=0.5 fontname=Arial
and I iterate through the array this way:
$A(attr.edges).each(function(edge) {
this.edge.set(id, new GraphEdge(cv, id, edge));
}, this);
But in Prototype's each method the 'edge' iterator (the Brainwriting
Object), returns zero length:
function $A(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
var length = iterable.length || 0, results = new Array(length);
// LENGTH NOW IS ZERO
while (length--) results[length] = iterable[length];
return results;
}
Maybe the Brainwriting Object is not iterable, but I would expect $A
(attr.edges) to have made it so before my call to each().
Surely I'm not expected to assign a length attribute to objects myself
- just lilke 'penwidth' and 'color' were assigned - in order to make
Array.each() work on objects. Why doesn't the Object.length return
non-zero when any kind of Object is instantiated?
I'm using Firefox 3.0.10.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---