Assign an index number to a javascript object key
<p><strong>Goal</strong>: The end goal is to have a method/technique of accessing the data of an object in a ordered list as well as calling methods like sort or map on the ordered list. If I can assign an index number to each key value then this should be possible. If we can assign an index to each key value of the object then the rest should fall into place either by creating a version of map and sort or inheriting them the Array object.</p>

<pre><code>var foo = { 
  bar : 'value',
  foobar : 'value2'
};

//the magic here

foo.bar // 'value'
foo[0] // 'value' (This is the ideal solution it does not have to be this way)
</code></pre>

<p><strong>Question</strong>: Is there a way to assign an index number to a javascript object key?</p>

<p><strong>Thoughts</strong>: I understand that javascript objects are hash tables so they have a key assigned to them but they are completely random and might change as you change the size of the hash table. So that wont work. </p>

<p>We can loop over the object and have a separate array that holds just the key value and then get the value by that key value number.</p>

<p>I'm really not sure of a good solution here I'm just throwing out my ideas, thoughts?</p>