Looking to get a head start on your next software interview? Pickup a copy of the best book to prepare: Cracking The Coding Interview!
push() method. For example, the following code adds the string “apple” to an array:
var fruits = ;
To add multiple elements to an array, you can pass them as arguments to the
push() method. For example:
fruits.push("banana", "orange", "pear");
var firstFruit = fruits;
splice() method. For example, the following code removes the second element from the array:
In this example, the first argument to
splice() is the index of the element to remove, and the second argument is the number of elements to remove.