Skip to content

Instantly share code, notes, and snippets.

@codenamev
Created December 13, 2011 14:04
Show Gist options
  • Save codenamev/1472229 to your computer and use it in GitHub Desktop.
Save codenamev/1472229 to your computer and use it in GitHub Desktop.
Remove a specific element from an array
// Array.splice(index, howmany, element_to_add_1,.....,element_to_add_X)
// Reference: http://www.w3schools.com/jsref/jsref_splice.asp
var myArray = [4,5,6];
var idx = visibleIds.indexOf(5); // Find the index
if(idx!=-1) visibleIds.splice(idx, 1); // Remove it! Returns --> [5]
// visibleIds is now --> [4, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment