JavaScript syntax: Difference between revisions

Content deleted Content added
No edit summary
m {{code}}
Line 467:
</syntaxhighlight>
 
[[Array data structure|Arrays]] are implemented so that only the defined elements use memory; they are "[[sparse array]]s". Setting {{Unstyled inline syntax|monospace=truecode|lang=javascript|code=myArray[10] = 'someThing'}} and {{Unstyled inline syntax|monospace=truecode|lang=javascript|code=myArray[57] = 'somethingOther'}} only uses space for these two elements, just like any other object. The <tt>length</tt> of the array will still be reported as 58.
 
One can use the object declaration literal to create objects that behave much like associative arrays in other languages: