lodash remove element from array
var colors = ["red","blue","green","green"];
var greens = _.remove(colors, function(c) {
return (c === "green"); //remove if color is green
});
//colors is now ["red","blue"]
//greens is now ["green","green"]var arr = [1, 2, 3, 3, 4, 5];
_.remove(arr, function(e) {
return e === 3;
});
console.log(arr);var a = [
{id: 1, name: 'A'},
{id: 2, name: 'B'},
{id: 3, name: 'C'},
{id: 4, name: 'D'}
];
var removeItem = [1,2];
removeItem.forEach(function(id){
var itemIndex = a.findIndex(i => i.id == id);
a.splice(itemIndex,1);
});
console.log(a);
Also in JavaScript:
- switch/case with numeric range
- get field type file js and loop
- first n elements of array js
- angular countdown timer
- javascript querySelectorAll to array
- javascript const
- how to add onclick to child element created javascript
- foreach async typescript
- number counter html
- traccar attributes list
- react native passing params to nested navigators
- rxjs que recibe como parametro un observable
- javascript cast bool to int
- javascript boolean change value
- redux acions
- left_field in jsgrid
- change span value javascript
- ojs link privacy page
- javascript string starts with
- how to read environment variable in node js
- react native vector icons not showing
- jquery on input
- javascript array reorder elements
- javascript string interpolation