Array Without First Element Code Example
Example 1: javascript remove first element from array
var arr = [1, 2, 3, 4]; var theRemovedElement = arr.shift(); // theRemovedElement == 1 console.log(arr); // [2, 3, 4]
Example 2: javascript remove first element from array
let numbers = ["I'm Not A Number!", 1, 2, 3]; numbers.shift();
Example 3: es6 remove first element of array
var myarray = ["item 1", "item 2", "item 3", "item 4"]; //removes the first element of the array, and returns that element. alert(myarray.shift()); //alerts "item 1" //removes the last element of the array, and returns that element. alert(myarray.pop()); //alerts "item 4"
Comments
Post a Comment