Associative array/Creation: Difference between revisions

→‎{{header|JavaScript}}: just added a missing verb in one place
(→‎{{header|MATLAB}} / {{header|Octave}}: limitation on the key string)
(→‎{{header|JavaScript}}: just added a missing verb in one place)
Line 740:
 
=={{header|JavaScript}}==
Javascript does not have associative arrays, however Objects (which are just an unordered bundle of name/value pairs) can be used like associative arrays. Javascript Arrays, which are just objects with a special length property and some handy inherited methods (such as pop, shift, slice, etc.), can be used as associative arrays too. However, by convention, Objects are most often used. Arrays are only used where access by numeric index is needed (such as when accessing values in numeric order) and use of the special length property is helpful (such as iterating from zero to array.length).
 
Javascript object property names (keys) are strings. Other types and expressions can be used with square bracket notation, they are evaluated and converted to strings and the result used as the property name:
Anonymous user