js数组
var arr=[1,2,3,4,5,6]## 标题
undefined
console.log(arr)
VM935:1 (6) [1, 2, 3, 4, 5, 6]0: 11: 2length: 2[[Prototype]]: Array(0)
undefined
arr.length
6
arr[0]=0
0
console.log(arr)
VM1069:1 (6) [0, 2, 3, 4, 5, 6]
undefined
arr.length=10
10
console.log(arr)
VM1162:1 (10) [0, 2, 3, 4, 5, 6, 空 ×4]
undefined
arr[7]
undefined
arr.length
10
arr.length=2
2
arr[0]
0
arr[0]=1
1
console.log(arr)
VM1439:1 (2) [1, 2]
undefined
arr.indexOf(2)
1
arr.indexOf(4)
-1
arr=[1,2,3,4,5,6]
(6) [1, 2, 3, 4, 5, 6]
arr.indexOf(1)
0
arr.indexOf(4)
3
arr.indexOf(6)
5
arr.slice(3)
(3) [4, 5, 6]
arr.slice(4)
(2) [5, 6]
arr.slice(5)
[6]
arr.slice(2)
(4) [3, 4, 5, 6]
arr.push('a','b')
8
arr.push('c','d')
10
arr
(10) [1, 2, 3, 4, 5, 6, 'a', 'b', 'c', 'd']
arr.pop()
'd'
arr.pop()
'c'
arr.pop()
'b'
arr.unshift('a','b')
9
arr
(9) ['a', 'b', 1, 2, 3, 4, 5, 6, 'a']
arr.shid
undefined
arr.shift()
'a'
console.log(arr)
VM2483:1 (8) ['b', 1, 2, 3, 4, 5, 6, 'a']
undefined
arr
(8) ['b', 1, 2, 3, 4, 5, 6, 'a']
arr
(8) ['b', 1, 2, 3, 4, 5, 6, 'a']
arr.sort()
(8) [1, 2, 3, 4, 5, 6, 'a', 'b']
ar.sort()
VM2596:1 Uncaught ReferenceError: ar is not defined
at <anonymous>:1:1
(匿名) @ VM2596:1
arr.sort()
(8) [1, 2, 3, 4, 5, 6, 'a', 'b']
arr.revise()
VM2702:1 Uncaught TypeError: arr.revise is not a function
at <anonymous>:1:5
(匿名) @ VM2702:1
arr.reverse()
(8) ['b', 'a', 6, 5, 4, 3, 2, 1]
arr.concat('s','d')
(10) ['b', 'a', 6, 5, 4, 3, 2, 1, 's', 'd']
arr.concat('w','r')
(10) ['b', 'a', 6, 5, 4, 3, 2, 1, 'w', 'r']
arr.jo\
VM2909:1 Uncaught SyntaxError: Invalid or unexpected token
arr.join('-')
'b-a-6-5-4-3-2-1'
arr=[[1,2],[3,4],[5,6]]
(3) [Array(2), Array(2), Array(2)]0: (2) [1, 2]1: (2) [3, 4]2: (2) [5, 6]length: 3[[Prototype]]: Array(0)at: ƒ at()concat: ƒ concat()constructor: ƒ Array()copyWithin: ƒ copyWithin()entries: ƒ entries()every: ƒ every()fill: ƒ fill()filter: ƒ filter()find: ƒ find()findIndex: ƒ findIndex()flat: ƒ flat()flatMap: ƒ flatMap()forEach: ƒ forEach()includes: ƒ includes()indexOf: ƒ indexOf()join: ƒ join()keys: ƒ keys()lastIndexOf: ƒ lastIndexOf()length: 0map: ƒ map()pop: ƒ pop()push: ƒ push()reduce: ƒ reduce()reduceRight: ƒ reduceRight()reverse: ƒ reverse()shift: ƒ shift()slice: ƒ slice()some: ƒ some()sort: ƒ sort()splice: ƒ splice()toLocaleString: ƒ toLocaleString()toString: ƒ toString()unshift: ƒ unshift()values: ƒ values()Symbol(Symbol.iterator): ƒ values()Symbol(Symbol.unscopables): {copyWithin: true, entries: true, fill: true, find: true, findIndex: true, …}[[Prototype]]: Object