Code Snippet

Home » Code Snippets » jQuery » Remove Specific Value from Array

Remove Specific Value from Array

var arr = [1, 2, 3, 4, 5];
var removeItem = 2;   

arr = $.grep(arr, function(value) {
  return value != removeItem;
});

Subscribe to The Thread

  1. Missing semicolon on the first line, other than that, cool beans

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~