Why does Array.splice(-1,1) remove last element in Javascript?
<p>I was trying to remove certain elements based on their index in array.
example:</p>

<pre><code>var x = ["a","b","c"];
</code></pre>

<p>and trying to do </p>

<pre><code>x.splice(x.indexOf("d"),1)
</code></pre>

<p>Since this turns out to be <code>x.splice(-1,1)</code> - it's ending up removing the element "c" from the array! </p>

<p>unable to understand why this is happening even though there is no cyclic property for Arrays in javascript.</p>