title: Are the advantages of Typed Arrays in JavaScript is that they work the same or similar in C?
body: <p>I've been playing around with <a href="https://developer.mozilla.org/en-US/docs/JavaScript_typed_arrays">Typed Arrays</a> in JavaScript.</p>
  
  <pre><code>var buffer = new ArrayBuffer(16);
  var int32View = new Int32Array(buffer);
  </code></pre>
  
  <p>I imagine normal arrays (<code>[1, 257, true])</code> in JavaScript have poor performance because their values could be of any type, therefore, reaching an offset in memory is not trivial.</p>
  
  <p>I originally thought that JavaScript array subscripts worked the same as objects (as they have many similarities), and were <a href="http://en.wikipedia.org/wiki/Hash_table">hash map</a> based, requiring a hash based lookup. But I haven't found much credible information to confirm this.</p>
  
  <p>So, I'd assume the reason why Typed Arrays perform so well is because they work like normal arrays in C, where they're always typed. Given the initial code example above, and wishing to get the 10th value in the typed array...</p>
  
  <pre><code>var value = int32View[10];
  </code></pre>
  
  <ul>
  <li>The type is <code>Int32</code>, so each value must consist of <code>32</code> bits or <code>4</code> bytes.</li>
  <li>The subscript is <code>10</code>.</li>
  <li>So the location in memory of that value is <code>&lt;array offset&gt; + (4 * 10)</code>, and then read <code>4</code> bytes to get the total value.</li>
  </ul>
  
  <p>I basically just want to confirm my assumptions. Is my thoughts around this correct, and if not, please elaborate. </p>
  
  <p>I checked out the <a href="https://github.com/v8/v8">V8 source</a> to see if I could answer it myself, but my C is rusty and I'm not too familiar with C++.</p>