Skip to main content Accessibility Feedback

Arrays

Array.prototype.shift()

Remove the first item from an array and returns it. The array is modified.

let wizards = ['Gandalf', 'Radagast', 'Merlin'];
let first = wizards.shift();

// logs "Gandalf"
console.log(first);

// logs ["Radagast", "Merlin"]
console.log(wizards);

Join the Lean Web Club! Coaching. Courses. Coding resources. Get the skills, confidence, and support you need to learn front-end web development and achieve long-term success.


Find this useful? You can support my work by purchasing an annual membership.