On Thu, Mar 10, 2011 at 9:00 PM, Charles Kendrick <[email protected]>wrote:
> People use Objects as classes, instances, "associative arrays" / Maps, etc.
> Numeric keys are a tiny minority and there would be no measurable
> performance gains for special treatment of such keys *on Object*.
>
An associative array is typically a hash map or perhaps a tree map. A
typical implementation will either iterate through such values in either an
undetermined order or in order by the keys -- preserving the insertion order
would be more expensive and preclude most options for implementation.
If you care about order, you don't use a hash map, and a JS object literal
seems more closely related to a hash map than anything else.
An alternative you didn't consider in your original post is using a single
array, which is guaranteed to not change the order and never pick up
additional properties:
selectControl.setOptions([
"storedValue1", "displayValue1",
"storedValue2", "displayValue2",
"storedValue3", "displayValue3"
])
--
John A. Tamplin
Software Engineer (GWT), Google
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss