Home >Web Front-end >JS Tutorial >What are the javascript array methods?
Javascript array methods include: concat(), join(), pop(), push(), reverse(), shift(), slice(), sort(), splice(), toSource() , toString(), unshift(), etc.
The operating environment of this tutorial: Windows 7 system, ECMAScript version 5, Dell G3 computer.
Array object
The Array object is used to store multiple values in a single variable.
Syntax for creating Array objects:
new Array(); new Array(size); new Array(element0, element1, ..., elementn);
Parameters
Parameter size is the expected number of array elements. In the returned array, the length field will be set to the value of size.
Parameters element ..., elementn is the parameter list. When the constructor Array() is called with these arguments, the elements of the newly created array are initialized to these values. Its length field will also be set to the number of parameters.
javascript Array object method
Method | Description |
---|---|
concat() | Concatenates two or more arrays and returns the result. |
join() | Put all elements of the array into a string. Elements are separated by the specified delimiter. |
pop() | Deletes and returns the last element of the array |
push() | Adds one or more elements to the end of an array and returns the new length. |
reverse() | Reverse the order of elements in the array. |
shift() | Delete and return the first element of the array |
slice() | Return selected elements from an existing array |
sort() | Sort the elements of the array |
splice() | Remove elements and add new elements to the array. |
toSource() | Returns the source code of the object. |
toString() | Convert the array to a string and return the result. |
toLocaleString() | Convert the array to a local array and return the result. |
unshift() | Adds one or more elements to the beginning of the array and returns the new length. |
valueOf() | Returns the original value of the array object |
For more programming-related knowledge, please visit : Programming Video! !
The above is the detailed content of What are the javascript array methods?. For more information, please follow other related articles on the PHP Chinese website!