rimuovere primo elemento da array e restituire la matrice meno il primo elemento
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"
- Come rimuovere il primo array, ma tornare la matrice meno il primo elemento
- Nel mio esempio dovrei get
"item 2", "item 3", "item 4"
quando rimuovo il primo elemento
'alert (array.slice (1))' o 'Array.shift(); alert (array); ' – Thomas
@Thomas quando uso' myarray.shift() 'restituisce' "elemento 1" 'quello che voglio è return' "item 2", "item 3", "item 4" ' –
Leggere per favore l'intero codice che ho scritto, usando 'shift()' – Thomas