title: Javascript 2d array indexOf
body: <p>I have a 2d array like this:</p>
  
  <pre><code>var arr = [[2,3],[5,8],[1,1],[0,9],[5,7]];
  </code></pre>
  
  <p>Each index stores an inner array containing the coordinates of some element.</p>
  
  <p>How can I use <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf" rel="noreferrer"><code>Array.indexOf()</code></a> to check if the newly generated set of coordinates is already contained in <code>arr</code>? I want to push into <code>arr</code> if only the coordinate is NOT a duplicate.</p>
  
  <p>Here is my attempt that didn't work:</p>
  
  <pre><code>if (arr.indexOf([x, y]) == -1) {
      arr.push([x, y]);
  }
  </code></pre>
  
  <p>It looks like <code>indexOf()</code> doesn't work for 2d arrays...</p>