Kar*_*nov -10 javascript
为什么这会返回1?
[].push([]); // outputs 1
Run Code Online (Sandbox Code Playgroud)
.push() 返回数组的新长度.
['one'].push('two'); // returns 2 (array length is 2)
['one', 'two'].push('something'); // returns 3 (array length is 3)
Run Code Online (Sandbox Code Playgroud)
在你的情况下:
[].push([]); // array length is 1 where you get array within array. [[]]
Run Code Online (Sandbox Code Playgroud)