IndexOf () The position of a character
Slice equivalent to a substring slice of string
A = [' A ', ' B ', [+] (5) ["A", "B", 1, 2, 3]a.slice (0,3) (3) ["A", "B", 1]a.slice (3 ) (2) [2, 3]
Append pop () after push () is removed from the back
A.push (' h ')7A (7) ["A", "B", 1, 2, 3, 4, "H"]a.pop ()"H"A (6) ["A", "B", 1, 2, 3, 4]
Unshift () in front of add shift () to delete the previous
A.unshift (7a) (7) [A, "a", "B", 1, 2, 3, 4]a.shift ()A (6) ["A", "B", 1, 2, 3, 4]
A.sort () sort
Reverse () Flip
splice(start, deleteCount, value, ...) 插入、删除或替换数组的元素 万能方法
obj.splice(n,
0
,val) 指定位置插入元素
obj.splice(n,
1
,val) 指定位置替换元素
obj.splice(n,
1
) 指定位置删除元素
A (6) [1, 2, 3, 4, "A", "B"]a.splice (2,0,8) []a (7) [1, 2, 8, 3, 4, "A", "B"]a.splice (2,1) [8]a (6) [1, 2, 3, 4, "A", "B"]a.splice (2,1,8) [3]a (6) [1, 2, 8, 4, "A", "B"]
Join () forms a string of array elements
a.join ()"1,2,8,4,a,b"
Learn JS array on the official website of Liao Xuefeng