1. concat method
[Function] Combine multiple arrays. This method does not change the existing array. It only returns a copy of the combined array.
[Syntax] arrayObj.concat(array1,array2,...)
[Example]
]
2. join Method, [Function] Convert the original array object into a string, which can be concatenated with the specified delimiter.
[Syntax] arrayObj.join(separator), separator is the separator, and the default is ",".
[Example]
If you need to introduce external Js, you need to refresh to execute
]
3. pop , shift method
[Function] The pop method deletes and returns the last element in the array, and at the same time, the length of the array changes. In contrast, the shift() method deletes and returns the first element of the array.
[Syntax] arrayObj.pop|shift()
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
4. push , unshift method
[Function] Add one or more elements to the end of the array and return the new length. At the same time, the length of the array will be changed, corresponding to the unshift method. Note that the return value of the method is not the new array, but the length of the new array.
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
] 5. reverse Method
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute ]
6. slice Method
[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]
7、sort方法
[作用] 用来对数组元素进行排序。
[语法] arrayObj.sort(sortRule())。参数可选,代表排序的方法。特别说明,sort排序有几个基本原则,第一,默认按照字母顺序排列;第二,大写字母排在小写字母之前。基与此,对于数字排序,需要自己写排序方法。
[实例]
8、splice方法 [作用] 向数组删除并加入新的元素。
[语法] arrayObj.splice(index,number,ele1,ele2...)。index为索引位置,必须为数字,代表从哪个位置插入或者删除元素。number,代表从index位置往后删除的元素个数,如果为“0”则表示在index插入新元素,不删除往后的数组元素。(说得太混了~~~直接看代码实例)
[实例]
9、toString方法 [作用] 使用率非常高的方法,直接将数组类型对象转换成字符串类型对象。
[语法] arrayObj.toString()
[实例]
注意:新的字符串是原数组连接而成,但是中间有“,”分隔,如想去掉“,”,可以这样写: