remove item from array if value is code example
Example 1: remove a value from array js
const index = array.indexOf(item);
if (index > -1) {
array.splice(index, 1);
}
Example 2: remove value from array javascript
// remove 5
let arr = [1,2,3,4,5,6];
let remove = arr.filter((id) => id !== 5)
console.log(remove) // [1,2,3,4,6]