codenamev
12/13/2011 - 2:04 PM

Remove a specific element from an array

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]