Arrays with JavaScript
Video
JavaScript Notes
JavaScript
var characters = ['Luke', 'Leia', 'Han', 'Chewie'];
console.log(characters);
console.log(characters.length);
console.log(characters[0]);
characters.push('Anakin'); //adds to the top of the array
characters.push('Obiwan'); //adds to the top of the array
characters.pop(); //removes top item from array
characters.pop(); //removes top item from array
characters.unshift('C3P0'); //adds to the bottom of the array
characters.unshift('R2D2'); //adds to the bottom of the array
characters.shift(); //removes first item from array
characters.shift(); //removes first item from array
Feedback
Submit and view feedback