First of all, what you're defining is not an array its an object and you're iterating all properties in the object here.
An array would be defined as "var arr = ['rose','stuff'];",
also if you try to define an array value by using "arr['rose'] = 'red';" you're adding a property to the "arr" object, you could replace this code also by writing "arr.rose = 'red';"
JavaScript has no associative arrays as you might know them from C# or Java Hashmaps.
WrongLJay April 24, 2012 at 6:06 AM
First of all, what you're defining is not an array its an object and you're iterating all properties in the object here. An array would be defined as "var arr = ['rose','stuff'];", also if you try to define an array value by using "arr['rose'] = 'red';" you're adding a property to the "arr" object, you could replace this code also by writing "arr.rose = 'red';" JavaScript has no associative arrays as you might know them from C# or Java Hashmaps.
ThanksPankaj July 10, 2012 at 10:27 PM
that was of help! :)
Post your Comment