Подтвердить что ты не робот

Удалить первый элемент из массива и вернуть массив за вычетом первого элемента

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"
4b9b3361

Ответ 1

Это должно удалить первый элемент, а затем вы можете вернуть оставшиеся:

var myarray = ["item 1", "item 2", "item 3", "item 4"];
    
myarray.shift();
alert(myarray);

Ответ 2

Попробуйте

    var myarray = ["item 1", "item 2", "item 3", "item 4"];

    //removes the first element of the array, and returns that element apart from item 1.
    myarray.shift(); 
    console.log(myarray); 

Ответ 3

Вы можете использовать array.slice(0,1)//Первый индекс удаляется и возвращается массив.