title: How to compare arrays in JavaScript?
body: <p>I'd like to compare two arrays... ideally, efficiently. Nothing fancy, just <code>true</code> if they are identical, and <code>false</code> if not. Not surprisingly, the comparison operator doesn't seem to work.</p>
  
  <pre><code>var a1 = [1,2,3];
  var a2 = [1,2,3];
  console.log(a1==a2);    // Returns false
  console.log(JSON.stringify(a1)==JSON.stringify(a2));    // Returns true
  </code></pre>
  
  <p>JSON encoding each array does, but is there a faster or "better" way to simply compare arrays without having to iterate through each value?</p>