remove certain elements from list javascript code example
Example 1: how to take an element out of an array in javascript
var data = [1, 2, 3];
// remove a specific value
// splice(starting index, how many values to remove);
data = data.splice(1, 1);
// data = [1, 3];
// remove last element
data = data.pop();
// data = [1, 2];
Example 2: js remove from array by value
const index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
Example 3: java script removing first three indexes
var indexToRemove = 0;
var numberToRemove = 1;
arr.splice(indexToRemove, numberToRemove);