Array.isArray()

Modifier method

The following methods change the value of the object calling them:

1. pop()

Removes the last element of the array and returns it.

2. push()

Adds one or more elements to the end of an array and returns the new length of the array.

3. shift()

Removes the first element of the array and returns it.

4. unshift()

Adds one or more elements to the beginning of an array and returns the new length of the array.

5. splice()

Adds or removes any element from an array at any location.

6. reverse()

Invert the order of the elements in an array, that is, the original first is changed to the last, and the original last is changed to the first.

7. sort()

Sorts array elements and returns the current array.

Access methods

The following methods never change the value of the object on which they are called, only returning a new array or some other expected value.

1. join()

Concatenate all array elements to form a string.

2. slice()

Extract an element from the current array to form a new array.

3. indexOf()

Returns the index of the first element in the array that is equal to the specified value, or -1 if no such element is found.

An iterative approach

1. forEach()

Executes a callback for each element in the array.

2. every()

Returns true if every element in the array satisfies the test function, false otherwise.

3. some()

Returns true if at least one element in the array satisfies the test function, false otherwise.

4. filter()

Puts all array elements that return true in the filter function into a new array and returns.

5. map()

Returns a new array of the return values of the callback function.

ES6 array new method

1. Array.from()

The array. from method is used to convert two types of objects into true arrays: array-like objects and iterable objects (including the new ES6 data structures Set and Map).

2. Array.of()

The array. of method converts a set of values to an Array. The main purpose of this method is to complement the Array constructor Array(). Array() behaves differently because of the number of arguments.

3. includes()

Checks whether the current array contains a specified value, returning true if so and false otherwise.

4. find()

Find the first element that satisfies the test function and return the value of that element, or undefined if not found.

5. findIndex()

Find the first element that satisfies the test function and return the index of that element, or -1 if not found.