js array remove first n elements code example
Example 1: javascript remove first element from array
var arr = [1, 2, 3, 4];
var theRemovedElement = arr.shift();
console.log(arr);
Example 2: javascript remove from array by index
array.splice(index, 1);
Example 3: remove first element from array javascript
const array1 = [1, 2, 3];
const firstElement = array1.shift();
console.log(array1);
console.log(firstElement);
Example 4: javascript remove first element from array
let numbers = ["I'm Not A Number!", 1, 2, 3];
numbers.shift();
Example 5: how to delete element in list javascript
let itemsToBeRemoved = ["Sunday", "Monday"]
var filteredArray = myArray.filter(item => !itemsToBeRemoved.includes(item))
Example 6: javascript array remove first
let yourArray = ["aaa", "bbb", "ccc", "ddd"];
yourArray.shift();