Short & Sweet — JavaScript Array Methods (part 1)
Arrays are used to store multiple values inside a single variable. They are kind of like a list of items. JavaScript has a lot of built in methods to work with arrays. Here are some popular ones.
.toString()
Converts an array to a string
.join()
Joins all elements in an array and turns them into a string (you can use different separators)
.concat()
Joins multiple arrays
.pop()
Remove last element from the end of an array
.push()
Add element to the end of an array
.shift()
Remove the first element from an array
.unshift()
Add new element to the beginning of an array
.sort()
Sorts the elements in an array. Default sorts them by ascending order.
.includes()
Check an array to see if it includes an element
.filter()
Creates a new array with every element in an array that pass the test that we provide it
References