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]
Remove a specific element (by value) from an Array.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.