title: Function to imitate Java's ArrayList.remove(o)
body: <p>How can I implement a function that does the same thing as <code>ArrayList.remove(o)</code>?</p>
  
  <p>The closest thing I have is</p>
  
  <pre><code>Array.prototype.remove = function(o) {
      var index = this.indexOf(o);
      if(index == -1) {
          return;
      }
      return this.splice(index, index);
  }
  </code></pre>
  
  <p>However it throws an error on the second line, claiming <code>indexOf(o)</code> doesn't exist. (<code>cannot find function indexOf()</code>)</p>