English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Arrays are used to store multiple values in a single variable.
The JavaScript Array object is a global object used to construct arrays.
var fruits = ["Apple", "Mango", "Banana"];Test to see if it is less than or equal to/›
The index of JavaScript arrays is zero: the index of the first element of the array is 0, the index of the second element is1and so on.
The index of the last element is equal to the length property value of the array minus1.
Using an invalid index number will return undefined.
You can use ourJavaScript Array arrayLearn aboutArray arrayMore information.
The following table lists the standard properties of the Array object:
Properties | Description |
---|---|
constructor | Return the function that creates the prototype of the Array object |
length | Set or return the number of elements in the array |
prototype | Allows you to add new properties and methods to the Array object |
The following table lists the standard methods of the Array object:
Method | Description |
---|---|
concat() | Merge two or more arrays and return a new array |
copyWithin() | Copy a series of array elements from one array to another |
entries() | Return the key/Value pair array iteration object |
every() | Check if each element in the array passes the test function |
fill() | Fill the elements in the array with static values |
filter() | Create a new array containing all elements that pass the test function |
find() | Return the value of the first element in the array that passes the test function |
findIndex() | Return the index of the first element in the array that passes the test function |
forEach() | Call a function once for each array element |
from() | Create an array from an object |
includes() | Determine if the array contains a certain element |
indexOf() | Search for an element in the array and return its first index |
isArray() | Determine if the passed value is an array |
join() | Join all elements of the array into a single string |
keys() | Returns an array iteration object containing the keys of the original array |
lastIndexOf() | Search for an element in the array from the end and return its last index |
map() | Create a new array and call a function for each array element |
pop() | Remove the last element from the array and return the element |
push() | Add one or more elements to the end of the array and return the new length of the array |
reduce() | Reduce the value of the array to a single value (from left to right) |
reduceRight() | Reduce the value of the array to a single value (from right to left) |
reverse() | Reverse the order of elements in the array; the first becomes the last, and the last becomes the first |
shift() | Remove the first element from the array and return the element |
slice() | Extract a part of the array and return a new array |
some() | Check if any element in the array passes the test in the test function |
sort() | Sort the elements of the array |
splice() | Add from the array/Delete an element |
toString() | Convert the array to a string and return the result |
unshift() | Add a new element to the beginning of the array and return the new length of the array |
valueOf() | Return the original value of the array |