VOOZH about

URL: https://www.geeksforgeeks.org/javascript/best-known-javascript-array-methods/

⇱ Best-Known JavaScript Array Methods - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Best-Known JavaScript Array Methods

Last Updated : 12 Jul, 2025

An array is a special variable in all programming languages used to store multiple elements. JavaScript array come with built-in methods that every developer should know how to use. These methods help in adding, removing, iterating, or manipulating data as per requirements.

👁 Image

There are some Basic JavaScript array methods which are as follows:

Array some() Method

The Array some() method checks if at least one element of the array satisfies the condition implemented by the provided function.

Example: To demonstrate the use of the Array some() method.


Output
true

Array reduce() Method

The array reduce() method reduces an array to a single value by executing a provided function for each value from left to right.

Example: Use the reduce() method to accumulate values, such as subtracting numbers.


Output
3

Array map() Method

The map() method in JavaScript creates a new array by calling a specific function on each element of the parent array. It does not mutate the original array.

Example: To demonstrate the use of the Array map() method.


Output
[ [ 2, 3, 4, 5 ], [ 2, 3, 4, 5 ], [ 2, 3, 4, 5 ], [ 2, 3, 4, 5 ] ]

Array every() Method

The Array every() method checks if all elements in the array satisfy a given condition provided by a function.

Example: To demonstrate the use of the Array every() method.


Output
true

Array flat() Method

The Array flat() method creates a new array that contains more than arrays. Basically creates a simple array from an array that contains multiple arrays.

Example: To demonstrate the use of the Array flat() method.


Output
[ 11, 89, 23, 7, 98 ]

Array flatMap() Method

This Array flatMap() method is used to flatten the input array element into a new array. This method first of all map every element with the help of a mapping function, then flattens the input array element into a new array.

Example: To demonstrate the use of the Array flatMap() method.


Output
[ 10, 20, 30, 40, 50 ]

Array filter() Method

The Array filter() method is used to create a new array from a given array consisting of only those elements from the given array which satisfy a condition set by the argument function.

Example: To demonstrate the use of the Array filter() Method.


Output
[ 112, 52, 944 ]

Array findindex() Method

The Array findIndex() method returns the index of the first element in a given array that satisfies the provided testing function. Otherwise, -1 is returned.

Example: To demonstrate the use of the Array.findindex() method.


Output
2

Array find() Method

The Array find() method is used to get the value of the first element in the array that satisfies the provided condition. It checks all the elements of the array and whichever the first element satisfies the condition is going to print.

Example: To demonstrate the use of the Array find() method.


Output
30

Array fill() Method

The Array fill() method is used to fill the array with a given static value. The value can be used to fill the entire array or it can be used to fill a part of the array.

Example: To demonstrate the use of the Array fill() Method.


Output
[ 1, 87, 87, 58 ]

Array forEach() Method

The Array forEach() method calls the provided function once for each element of the array. The provided function may perform any kind of operation on the elements of the given array.

Example: To demonstrate the use of the Array forEach() Method.


Output
[ 1, 841, 2209 ]

Array sort() Method

The Array sort() method is used to sort the array. An array can be of any type i.e. string, numbers, characters, etc.

Example: To demonstrate the use of the Array sort() Method.


Output
[ 10, 25, 50, 88 ]

Array concat() Method

The Array concat() method is used to merge two or more arrays together. This function does not alter the original arrays passed as arguments.

Example: To demonstrate the use of the Array concat() Method.


Output
[
 11, 12, 13, 14, 15,
 16, 17, 18, 19
]

Array includes() Method

The Array includes() method is used to know whether a particular element is present in the array or not and accordingly, it returns true or false i.e, if the element is present, then it returns true otherwise false

Example: To demonstrate the use of the Array includes() Method.


Output
true

Array reverse() Method

The Array reverse() method is used for in-place reversal of the array. The first element of the array becomes the last element and vice versa.

Example: To demonstrate the use of the Array reverse() method.


Output
Original array: 34,234,567,4
Newly reversed array: 4,567,234,34
Comment