Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how remove an element on an array in the beginning on js

The shift() method removes the 
first element from an array and
 returns that removed element. 
 This method changes the length of the array.


example:

var colors = [ 'red','white', 'blue'];

colors.shift(); 
console.log(colors)

// colors = [ 'white', 'blue']

var numbers = [1, 2, 3, 4, 5];
numbers.shift();

console.log(numbers);
//  numbers: [  2, 3, 4, 5 ]
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #remove #element #array #beginning #js
ADD COMMENT
Topic
Name
7+6 =