Most Useful JavaScript Array Functions

Image for post
Image for post

You might have found the first article very much useful and this article is an extension of the 10 most useful JavaScript array methods. The following functions are widely used in industry and make the JavaScript code clean, modularized, and easy to understand.


The find() method returns the value of the first element in the provided array that satisfies the provided testing function. If it finds an array element where the function returns a true value, find() returns the value of that array element (does not check the remaining values) Otherwise, it returns undefined.


The findIndex() method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.


The slice() method returns the selected elements in an array, as a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.

You may also like: How to use Local Storage

Note: slice does not alter the original array. It returns a shallow copy of elements from the original array.


The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array. The removed element from the array; undefined if the array is empty.


The entries() method returns an Array Iterator object with key/value pairs for each index in the array.

Iterating with index and element using for loop


The isArray() method checks whether the passed value is an array. This function returns true if the passed value is an array, otherwise returns false.

For backward compatibility, you can add the following

Note: Only implement if no native implementation is available


The sort() method sorts the elements of an array in place and returns the sorted array. The sort order can be either alphabetic or numeric, and either ascending or descending. By default, the sort() method sorts the values as strings in alphabetical and ascending order.

Now if you want to sort the above example as an ascending order then you need to use compareFunction. Let’s see the below example.


The concat() method is used to combine two or more arrays into a new array. This method does not change the existing arrays but instead returns a new array.

You may also like: JavaScript Tips & Tricks

Originally published at

Coding Hub — Learn & Build Your Career

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store