How do I store complex objects in javascript?
<p>I need to be able to store objects in javascript, and access them very quickly. For example, I have a list of vehicles, defined like so:</p>

<pre><code>{ "name": "Jim's Ford Focus", "color": "white", isDamaged: true, wheels: 4 }
{ "name": "Bob's Suzuki Swift", "color": "green", isDamaged: false, wheels: 4 }
{ "name": "Alex's Harley Davidson", "color": "black", isDamaged: false, wheels: 2 }
</code></pre>

<p>There will potentially be hundreds of these vehicle entries, which might be accessed thousands of times. I need to be able to access them as fast as possible, ideally in some useful way.</p>

<p>For example, I could store the objects in an array. Then I could simply say <code>vehicles[0]</code> to get the Ford Focus entry, <code>vehicles[1]</code> to get the Suzuki Swift entry, etc. However, how do I know which entry is the Ford Focus?</p>

<p>I want to simply ask "find me Jim's Ford Focus" and have the object returned to me, as fast as possible. For example, in another language, I might use a hash table, indexed by name. How can I do this in javascript? Or, is there a better way?</p>

<p>Thanks.</p>
