Created
December 13, 2011 14:04
-
-
Save codenamev/1472229 to your computer and use it in GitHub Desktop.
Remove a specific element from an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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