How to removes the first element of an array and returns that element in JavaScript

1 Answer

0 votes
var numbers = [3, 1, 100, 90];

var n = numbers.shift();

document.write(n + "<br />");
document.write(numbers);


/*

run:

3
1,100,90 

*/

 



answered Apr 7, 2017 by avibootz
...