title: How are objects in JavaScript stored in memory?
body: <p>On the official documentation of <a href="http://www.json.org" rel="noreferrer">JSON</a></p>
  
  <blockquote>
    <p>An object is an unordered set of name/value pairs. An object begins
    with { (left brace) and ends with } (right brace). Each name is
    followed by : (colon) and the name/value pairs are separated by ,
    (comma).</p>
  </blockquote>
  
  <p><strong>Note</strong>
  I am Javascript newbie, and from the name JSON (Javascript object notation) itself, I am assuming objects in Javascript are same as JSON. Please correct me in case I have got it wrong.</p>
  
  <p>From the above definition it seems the Javascript objects are most probably implemented by either a hashmap or a BST or some similar data-structure.</p>
  
  <p>But when I insert key value pairs in <strong>Node</strong> shell, they are inserted in serialised manner. This is what I tried in node shell</p>
  
  <pre><code>&gt; var a = {}
  undefined
  &gt; a['k1'] = 'a1'
  'a1'
  &gt; a['k3'] = 'a3'
  'a3'
  &gt; a['k2'] = 'a2'
  'a2'
  &gt; a['k4'] = 'a4'
  'a4'
  &gt; a['k5'] = 'a5'
  'a5'
  &gt; a
  { k1: 'a1',
    k3: 'a3',
    k2: 'a2',
    k4: 'a4',
    k5: 'a5' }
  </code></pre>
  
  <p>Now, on printing <code>a</code> the key value pairs are returned in the same order as that of insertion. So my questions are:</p>
  
  <ul>
  <li>Do I get fast lookups for a key? I mean complexity of O(log(n)) or better.</li>
  <li>In case JSON is not using a data-structure like a BST, hashmap or some similar DS, then how exactly are JSON objects layed under the memory?</li>
  </ul>
  
  <p><strong>Update</strong>
  Ok, so what about Javascript objects. Can someone comment on the underlying implementation of Javascript objects.</p>