how to remove number from array in javascript code example
Example 1: remove a particular element from array
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");
colors.splice(carIndex, 1);
Example 2: remove a value from array js
const index = array.indexOf(item);
if (index > -1) {
array.splice(index, 1);
}
Example 3: remove a value to an array of javascript
var data = [1, 2, 3];
data.splice(1, 1);
data.pop();
Example 4: exclude vales from array in js
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var filtered = array.filter(function(value, index, arr){
return value > 5;
});
Example 5: remove number from array javascript
remove number from array javascript