Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Find the <code>index</code> of the array element you want to remove, then remove that index with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice" rel="noreferrer"><code>splice</code></a>.</p> <blockquote> <p>The splice() method changes the contents of an array by removing existing elements and/or adding new elements.</p> </blockquote> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var array = [2, 5, 9]; console.log(array) var index = array.indexOf(5); if (index &gt; -1) { array.splice(index, 1); } // array = [2, 9] console.log(array);</code></pre> </div> </div> </p> <p>The second parameter of <code>splice</code> is the number of elements to remove. Note that <code>splice</code> modifies the array in place and returns a new array containing the elements that have been removed.</p> <hr> <p><strong><em>Note</strong>: <a href="http://kangax.github.io/compat-table/es5/#test-Array.prototype.indexOf" rel="noreferrer">browser support for indexOf</a> is limited</em>; it is not supported in Internet&nbsp;Explorer 7 and 8.</p> <p>If you need <code>indexOf</code> in an unsupported browser, try the following <code>polyfill</code>. Find more info about this <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill" rel="noreferrer"><strong><em><code>polyfill</code> here</em></strong></a>.</p> <pre><code>Array.prototype.indexOf || (Array.prototype.indexOf = function(d, e) { var a; if (null == this) throw new TypeError('"this" is null or not defined'); var c = Object(this), b = c.length &gt;&gt;&gt; 0; if (0 === b) return -1; a = +e || 0; Infinity === Math.abs(a) &amp;&amp; (a = 0); if (a &gt;= b) return -1; for (a = Math.max(0 &lt;= a ? a : b - Math.abs(a), 0); a &lt; b;) { if (a in c &amp;&amp; c[a] === d) return a; a++ } return -1 }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload