August 31, 2020
4 min read
Probably anyone reading this knows what an array is but let's revise a bit.
What is a Array?
Simply, an array is a variable (a very special one) that holds more than one value. So you can keep an unlimited number of values in it and it is much helpful and easier to work with than declaring and assigning each variable all over again.
Array's can be created by
 with the elements seperated by
, or if you want to be nerdy, you can use
Let's get to why we are here. Array Methods.
The concat method is used to add two arrays as one.
The join method joins the elements of an array by a given string which it takes as the argument and returns the string value.
The slice() method returns the selected elements in an array, as a new array object without changing the original array. It selects the elements starting at the given start argument, and ends at, but does not include, the given end argument.
It returns the index value of an element in an array.
It returns the last index value of an element in an array if the same element repeats itself more than one.
It returns the array reversed.
The sort method is used to sort elements of the array alphabetically.
The shift method removes the first element of the array shifts the values at consecutive indexes down, then returns the removed value.
The unshift method adds new items to the beginning of an array and returns the new length.
The pop method removes the last element of an array and returns the element removed.
The opposite of the unshift method. The push method adds new items to the end of an array and returns the new length.
The splice method replaces the element in an array from one position to another and returns the element that was replaced.