Adding Data to Arrays8:02 with Dave McFarland
Learn three common ways to add values to arrays.
Add items to the end of an array with
var items = ['Hat', 'Ball', 'Shoes']; items.push('Socks','Scarf'); // items is now ['Hat', 'Ball', 'Shoes', 'Socks', 'Scarf']
Add items to the beginning of an array with
var items = ['Hat', 'Ball', 'Shoes']; items.unshift('Socks','Scarf'); // items is now ['Socks', 'Scarf', 'Hat', 'Ball', 'Shoes']
You need to sign up for Treehouse in order to download course files.Sign up