类型的东西返回对象而不是数组

Jen*_*er 5 javascript jquery

x 是一个数组。

console.log(x)知道了

[ 'value' ]
Run Code Online (Sandbox Code Playgroud)

但是当我检查x的类型console.log(typeof x)时说它是一个对象。为什么?

Cha*_*lie 6

数组是 JS 中的对象。

如果您需要测试数组的变量:

if (x.constructor === Array)
   console.log('its an array');
Run Code Online (Sandbox Code Playgroud)


Alt*_*yss 0

数组是一个对象类型,所以没问题!