Basic JavaScript (44/111) | Manipulate Arrays With shift | freeCodeCamp
pop() always removes the last element of an array. What if you want to remove the first?
That's where .shift() comes in. It works just like .pop(), except it removes the first element instead of the last.
Example:
var ourArray = ["Stimpson", "J", ["cat"]];
var removedFromOurArray = ourArray.shift();
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].
Use the .shift() function to remove the first item from myArray, assigning the "shifted off" value to removedFromMyArray.
https://www.freecodecamp.org/learn/ja...
Sur cette page du site, vous pouvez voir la vidéo en ligne Basic JavaScript (44/111) | Manipulate Arrays With shift | freeCodeCamp durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Stral Tech 07 septembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 375 fois et il a aimé 1 téléspectateurs. Bon visionnage!