Answers for "how to remove array"

8

remove array elements javascript

let forDeletion = [2, 3, 5]

let arr = [1, 2, 3, 4, 5, 3]

arr = arr.filter(item => !forDeletion.includes(item))
// !!! Read below about array.includes(...) support !!!

console.log(arr)
// [ 1, 4 ]
Posted by: Guest on June-07-2020
8

delete from array javascript

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];var removed = arr.splice(2,2);/*removed === [3, 4]arr === [1, 2, 5, 6, 7, 8, 9, 0]*/
Posted by: Guest on April-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language