The easiest way is using shift(). If you have an array, the shift function shifts everything to the left.
var arr = [1, 2, 3, 4];
var theRemovedElement = arr.shift(); // theRemovedElement == 1
console.log(arr); // [2, 3, 4]
Answer from Thalsan on Stack OverflowThe easiest way is using shift(). If you have an array, the shift function shifts everything to the left.
var arr = [1, 2, 3, 4];
var theRemovedElement = arr.shift(); // theRemovedElement == 1
console.log(arr); // [2, 3, 4]
Just use arr.slice(startingIndex, endingIndex).
If you do not specify the endingIndex, it returns all the items starting from the index provided.
In your case arr=arr.slice(1).
Videos
Plain javascript will do:
data.urls.shift()
On shift() method:
Removes the first element from an array and returns that element. This method changes the length of the array.
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift
There's a method like pop, but from the front instead
data.urls.shift()
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift
The .shift() method removes the first element of an array. Then you can return the remaining:
const array = ["item 1", "item 2", "item 3", "item 4"];
array.shift();
console.log(array);
As others have suggested, you could also use slice(1):
const array = ["item 1", "item 2", "item 3", "item 4"];
console.log(array.slice(1));
Why not use ES6?
const array = ["item 1", "item 2", "item 3", "item 4"];
const [, ...rest] = array;
console.log(rest)