Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Arrayobj = new Array () creates an array.
Arrayobj = new Array ([size]) creates an array and specifies the length, not the upper limit, but the length.
Arrayobj = new Array ([element0[, element1[, ...) [, ELEMENTN]]] Creates an array and assigns a value.
Arrayobj = [Element0, Element1, ..., ELEMENTN] Create an array and assign a shortened shorthand, note that the parentheses here do not indicate an omission.
To illustrate, although the second method creates an array that specifies the length, in all cases the array is longer, that is, even if you specify a length of 5, you can still store the elements outside the specified length, note: the length changes.
Does the new array (5) mean creating an array of length 5 or an array with an element value of 5? Create an array of length 5.
Are the array subscripts starting at 0 or starting at 1? Starting from 0, the upper bound of the array equals the length of the array-1.
What is the maximum value of an array subscript? 2 of 32 times to reduce 2, that is 4294967295, about 4 billion, enough.
Will the array be automatically rounded when it is marked as a decimal? No, a run-time error is ignored or occurs.
Do you support multidimensional arrays? Not supported! However, you can redefine each element of an array to an array to achieve the purpose of multidimensional arrays.
How do I access an array element? Using "", such as an array named arr, to access the first element, use Arr.
POPs and Push:pop remove the last element and return the element value; push ([Item1 [item2]. [Itemn]]]) Adds one or more new elements to the end of the array and returns the new length of the array, and if you add an array, concatenate the elements of the array with commas before adding them.
Shift and Unshift: respectively correspond to pops and push, except that this is done at the beginning of the array. Note When you remove or add an element from the start position, the elements in the array are moved forward or moved back.
Slice and Splice:slice (start, [end]) return a portion of an array as an array, noting that the end-corresponding element is not included, if the end will copy all the elements after start; splice (Start, deletecount, [i tem1[, item2[, ... [, Itemn]]] Remove one or more elements of an array, if necessary, insert a new element in the position of the removed element, return the removed element as the form, and insert the first element of the array if the array is inserted.
Reverse and Sort:reverse () invert elements (top to bottom and last), and return array addresses; sort () array sorted and returns the address of the arrays.
Concat and Join:concat concatenate multiple arrays (or strings) into an array; join (separator) returns a string that joins each element value of the array, separated by separator.
toLocaleString, toString, valueof: Can be seen as a special use of join, not commonly used.
More basic information can be viewed: JS array
Delete methods for elements in the JScript built-in object array
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.