delete value from array code example
Example 1: remove a value from array js
const index = array.indexOf(item);
if (index > -1) {
array.splice(index, 1);
}
Example 2: how to delete an element from an array
var array = [123, "yee", true];
array.pop(index);
Example 3: delete from array based on value javascript
var index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
Example 4: remove a value to an array of javascript
var data = [1, 2, 3];
data.splice(1, 1);
data.pop();
Example 5: delete an item from array javascript
let items = [12, 548 ,'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' ,2154 , 119 ];
items.length;
items.splice(3,1) ;
items.length;
Example 6: 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;
});