Since JavaScript Arrays are modified objects, each and every Array you create has a few core methods.
- What's really interesting is that some of these methods implement basic data structures you'd normally have to write yourself such as stacks (push, pop) and queues (shift, unshift).
concat() | Joins two or more arrays and returns the result |
indexOf() | indexOf(searchElement[, fromIndex) searches the array for searchElement and returns the index of the first match. |
join() | Puts all the elements of an array into a string. The elements are separated by a specified delimiter |
lastIndexOf() | lastIndexOf(searchElement[, fromIndex) like indexOf, but starts at the end and searches backwards. |
pop() | Removes and returns the last element of an array |
push() | Adds one or more elements to the end of an array and returns the new length |
reverse() | Reverses the order of the elements in an array |
shift() | Removes and returns the first element of an array |
slice() | Returns selected elements from an existing array |
sort() | Sorts the elements of an array |
splice() | Removes and adds new elements to an array |
toSource() | Represents the source code of an object |
toString() | Converts an array to a string and returns the result |
unshift() | Adds one or more elements to the beginning of an array and returns the new length |
valueOf() | Returns the primitive value of an Array object |