Array Methods in JavaScript
Array Methods in JavaScript
Array Methods
push() sort() indexOf()
every() forEach()
are
d sh
e an
lik
@linkinsunil swipe @officialskv
1
push()
Adds one or more elements to the end of
an array and returns the new length of the
array..
pop()
Removes the last element from an array
and returns that element.
shift()
Removes the first element from an array
and returns that element.
unshift()
Adds one or more elements to the
beginning of an array and returns the new
length of the array.
find()
Returns the value of the first element in the
array that satisfies the provided testing
function. Otherwise, undefined is returned.
some()
Tests whether at least one element in the
array passes the test implemented by the
provided function. It returns true if any
element passes the test, otherwise it
returns false.
every()
Tests whether all elements in the array
pass the test implemented by the provided
function. It returns true if all elements pass
the test, otherwise it returns false.
sort()
Sorts the elements of an array in place and
returns the sorted array. The default sort
order is built upon converting the elements
into strings, then comparing their
sequences of UTF-16 code units values.
includes()
Determines whether an array includes a
certain element, returning true or false as
appropriate.
slice()
Returns a shallow copy of a portion of an
array into a new array object selected
from start to end (end not included). The
original array will not be modified.
map()
Creates a new array with the results of
calling a provided function on every
element in the calling array.
filter()
Creates a new array with all elements that
pass the test implemented by the provided
function.
reduce()
Executes a reducer function on each
element of the array, resulting in a single
output value.
forEach()
Executes a provided function once for each
array element.
indexOf()
Returns the first index at which a given
element can be found in the array, or -1 if it
is not present.
lastIndexOf()
Returns the last index at which a given
element can be found in the array, or -1 if it
is not present.
reverse()
Reverses the order of the elements of an
array in place. The first element becomes
the last, and the last element becomes the
first.
concat()
Returns a new array that includes
elements from the original array and
additional elements.
join()
Joins all elements of an array into a string.
The elements are separated by a specified
separator string.
toString()
Returns a string representing the specified
number or array and its elements.
Frontend Developer