Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

JavaScript Array object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


JavaScript Array object


Array object

Array objects are used to store multiple values in variables:

var cars = [ "Saab" , "Volvo" , "BMW" ];

The index value of the first array element is 0, the second index value is 1, and so on.

For more information about the JavaScript Array Reference Manual, please refer to the JavaScript Array Object Manual.


Array object method

Method Describe
concat() Connect two or more arrays and return the results.
every() Detects whether each element of the Array element is eligible.
filter() Detects the Array element and returns an array of all elements that meet the criteria.
indexOf() Search for the element in the array and return where it is located.
join() Put all elements of the array into a string.
lastIndexOf() Returns the last place where a specified string value appears, and searches forward from behind at the specified location in a string.
map() Each element of the array is processed by specifying a function, and the processed array is returned.
pop() Delete the last element of the array and return the deleted element.
push() Add one or more elements to the end of the array and return a new length.
reverse() Inverse the order of the elements of the array.
shift() Delete the first element of the array.
slice() Select part of the array and return a new array.
some() Detects if an element in an array element meets the specified criteria.
sort() Sort the elements of the array.
splice() Add or remove elements from an array.
toString() Convert the array to a string and return the result.
unshift() Add one or more elements to the beginning of the array and return a new length.
valueOf() Returns the original value of the array object.