Array

Example

1

Description

Properties

Property Name Description
constructor function that created the Array object's prototype
length sets or returns the number of elements in an array
prototype allows adding properties and methods to the object

Methods

Method Name Description Values
every() Returns true if every element in this array satisfies the provided testing function.
filter() Creates a new array with all of the elements of this array for which the provided filtering function returns true.
forEach() Calls a function for each element in the array.
indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
isArray() Returns true if the passed argument is an array.
join() Joins all elements of the Array into a String, and returns the String. If no separator is provided, comma is used.
lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
map() Creates a new array with the results of calling a provided function on every element in this array.
pop() Removes the last element of the Array, and returns that element.
push() Adds new elements to the end of the Array, and returns the new length.
reduce() Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
reduceRight() Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.
reverse() Reverses the order of the elements in the Array.
shift() Removes and returns the first element of the Array.
slice() Returns a slice of the Array from the start index to the end index as a new Array.
some() Returns true if at least one element in this array satisfies the provided testing function.
sort() sorts the Array according to sortFunction.
splice() Adds or removes elements at the specified Array index, modifying the original Array and returning a new Array. If the number to remove is 0, provide elements to be added.
toString() Returns a String representation of the Array.
unshift() Adds new elements to the beginning of the Array.
valueOf() Returns the primitive value of the Array.