title: Clearing up the `hidden classes` concept of V8
body: <p>I've read some articles about V8's hidden classes. However, I still have a few questions in my head:</p>
  
  <p>If, let's say, there are two objects:</p>
  
  <pre><code>var a = { }
  a.x = 5
  a.y = 6
  
  var b = { }
  b.y = 7
  b.x = 8
  </code></pre>
  
  <p>Do they end up with the same hidden class or separate just because one went <code>0 + x + y</code> and the other <code>0 + y + x</code>? As I understood, they get different classes but just wanna make sure I got it.</p>
  
  <p>Then, we have this case:</p>
  
  <pre><code>function Point(x, y) {
      this.x = x
      this.y = y
  }
  var a = new Point(7, 8)
  
  var b = { }
  b.x = 6
  b.y = 8
  
  var c = {
      x: 8,
      y: 9
  }
  
  var d = {
      y: 9,
      x: 80
  }
  </code></pre>
  
  <p>Do we end up with the same hidden class? I might guess that <code>a</code>, <code>b</code> and <code>c</code> do but <code>d</code> doesn't. Unless there is some sorting done on such object expressions (similarly to array's short declaration being analysed for the type).</p>
  
  <p>Finally, we have this:</p>
  
  <pre><code>function PointA(x, y) {
      this.x = x
      this.y = y
  }
  var a = new PointA(7, 8)
  
  function PointB(x, y) {
      this.x = x
      this.y = y
  }
  var b = new PointB(7, 8)
  </code></pre>
  
  <p>It is sorta similar to the second case. These objects seem the same except that their origin (<code>instanceof...</code>) is different. However, do there objects end up with the same hidden class?</p>