JohnPaulDesign
4/14/2019 - 4:41 PM

Arrays

// Arrays are variables with multiple values

const fruits = ['apples', 'oranges', 'pears'];

// Methods to manipulate an array

fruits.push('mangos'); // adds a value to the end of array

fruits.unshift('strawberries'); // adds to beginning

fruits.pop('strawberries'); // takes off the last value

console.log(Array.isArray(fruits)); // checks if param is array

console.log(fruits.indexOf('oranges')); // get the index number of a certain value

console.log(fruits);

// The old way of assigning an array is:
const numbers = new Array(1,2,3,4,5);