Associative Arrays part 1


Associative Arrays
46
1/2












Associative Arrays
While many programming languages support arrays with named indexes (text instead of numbers), called associative arrays,JavaScript does not.
However, you still can use the named arraysyntax, which will produce an object.
For example:
Now, person is treated as an object, instead of being an array.
The named indexes "name" and "age" become properties of the person object.
As the person array is treated as an object, the standard array methods and properties will produce incorrect results. For example, person.length will return 0.
Comments
Post a Comment