arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
let a = arr.reduce(function (a, b, i) {
a.i = b
return a
}, {})
结果:{ i: 13 }
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
let a = arr.reduce(function (a, b, i) {
a[i] = b
return a
}, {})
结果:
{ 0: 1
1: 2
2: 3
3: 4
4: 5
5: 6
6: 7
7: 8
8: 9
9: 10
10: 11
11: 12
12: 13 }
想知道为什么第一种和预想的不一样