Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Removing Items From Arrays4:20 with Dave McFarland
Learn how to remove values from the front an end of an array.
Remove the First Item from an array with
var items = ['Hat', 'Ball', 'Shoes']; var firstItem = items.shift(); // firstItem now holds 'Hat' // and items is now ['Ball', 'Shoes']
Remove the Last Item from an array with
var items = ['Hat', 'Ball', 'Shoes']; var lastItem = items.pop(); // lastItem now holds 'Shoes' // and items is now ['Hat', 'Ball']
You need to sign up for Treehouse in order to download course files.Sign up