add value to array withtout delete it javascript code example
Example 1: js remove from array by value
const index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
Example 2: js remove if
ar = [1, 2, 3, 4];
ar = ar.filter(item => !(item > 3));
console.log(ar) // [1, 2, 3]