The JavaScript object simply does not have a length property, only Arrays . If you want to know the number of properties that are defined on an object, you must iterate over them and read them.
Also, your for in loop is prone to errors related to the Object.prototype extension, as it will go through a prototype chain and lists all the properties that are on the chain.
Example
// Poisoning Object.prototype Object.prototype.bar = 1; var foo = {moo: 2}; for(var i in foo) { console.log(i); // logs both 'moo' AND 'bar' }
You must use the hasOwnProperty method of the object to filter out these unwanted properties.
// still the foo from above for(var i in foo) { if (foo.hasOwnProperty(i)) { console.log(i); // only logs 'moo' } }
Many JavaScript frameworks there extend the prototype, and without using hasOwnProperty , often lead to terrible errors.
Update
Regarding the real problem, that your code is not an animation of both properties.
for(var p in properties) { ... for(var i = 0; i <= frames; i++) { setTimeout((function(exti, element) { return function() {
Ivo Wetzel Jan 14 '11 at 11:31 2011-01-14 11:31
source share