Available in Chrome 45+ | View on GitHub | Browse Samples
ECMAScript 2015 specification adds additional static methods on
Array and instance
Array.from() method converts an array-like object to a true
array. It takes an optional second parameter, which can be used to execute a map
function on each element of the array that is being created.
It comes in handy when dealing with the infamous
Array.of() method creates a new
with any number of arguments, regardless of their type.
copyWithin() method copies the sequence of array elements
within the array to the position starting at
target. The copy is
taken from the index positions of the second and third arguments
end argument is
optional and defaults to the length of the array.
start is negative, it will be treated as
length is the length of the array. If
end is negative, it will be treated as
fill() method fills all the elements of an array between an
start index and an optional
end index with a
start argument defaults to 0. The
argument defaults to the length of the array.
find() method returns a value in the array, if at least one
element in the array satisfies the provided
predicate function. If
undefined is returned.
find() does not mutate
the array on which it is called.
findIndex() method returns an index in the array, if at least
one element in the array satisfies the provided
function. If not, -1 is returned.
findIndex() does not mutate the
array on which it is called.