JavaScript: Array functions/methods

Javascript is a web programming language used in modern web development. Many frameworks and libraries built in Javascript like Angular, React, Jquery, etc.

Arrays are the data structure that can store a collection of elements of the same type. To perform a different type of operation on an array we have some built-in javascript array functions or methods.

Take a look at the below list to see Javascript array functions. An array is a container to store a group of data in a single variable.


1. toString()	
converts an array to a string of (comma separated) array values

2. join()	        
converts an array to a string (we can specify the separator).

3. pop()	        
removes the last element from an array

4. push()	        
adds a new element to an array (at the end)

5. shift()	        
removes the first array element and "shifts" all other elements to a lower index

6. unshift()	
adds a new element to an array (at the beginning), and "unshifts" older elements

7. splice()	
add new items to an array

8. concat()	
creates a new array by merging (concatenating) existing arrays

9. slice()	        
slices out a piece of an array into a new array

10. sort()	        
sorts an array alphabetically

11. reverse()	
method reverses the elements in an array

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *