Definition of JS array object and related properties and methods

array:

Array objects in JS are essentially the same as collections in Java, and their length is variable. Elements can be of any object type.

definition:

new Array();
 new Array(size);
 new Array(element0, element1, ..., elementn);
 var array = [element0,element1,...,elementn]; 
//Define a two-dimensional array
var array2w = [ [element0,element1,...,elementn], [element0,element1,...,elementn], [element0,element1,...,elementn] ];

Common attributes: length

Common method:

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() Remove and return the last element of an array
push() Adds one or more elements to the end of the array and returns the new length.
reverse() Reverse the order of elements in an array.
shift() Remove and return the first element of an array
sort() Sort the elements of an array
toString() Convert the array to a string and return the result.
unshift() Adds one or more elements to the beginning of the array and returns the new length.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324888817&siteId=291194637