2. CREATING ARRAYS
• var a = [ ]; // this creates an empty
• var numbers = [1,2,3,4,5,6]; // this creates an array
of numbers
3. ACCESSING ARRAY ITEMS
• How to Access a Single Element in an array
• Example var friends = [‘Florence’,‘Seth’,‘Richard’];
• friends[0]; // evaluates to Florence
• friends[2]; // evaluates to Richard
5. THE LENGTH PROPERTY
• The Length; property gives the array length
• var friends = [‘Florence’,‘Seth’,‘Hunter’];
• friends.length; // evaluates to 3
6. PUSH AND UNSHIFT
• var cars = [‘BMW’,‘Lexus’,‘Toyota’,‘Honda’];
• cars.push(‘Tesla’,‘Jaguar’); // Push properties adds
elements to the end of the array.
• cars.unshift(‘Jeep’,‘Ford’); // Adds items to the front
of the array.
7. POP AND SHIFT
• Both Pop and Shift Methods Remove Items from the array
• var fruits = [‘Apples’,‘Oranges’,‘Mangos’,‘Grapes’];
• fruits.pop(); // removes the last item from the array, i.e.
grapes
• fruits.shift(); // removes the first item from the array, ie.
removes Apples
9. ARRAY HELPERS
• var name = [‘Bob Marley’,‘Led Zeplin’,‘Zig Ziglar’];
• name.sort();// sort the array of names,
• name.reverse(); // reverse the order of the array
• You can find additional helpers on problem 7Year
Up Chrome Extension