x is an array.
x
I use console.log(x) and the output result is
console.log(x)
[ 'value' ]
But when I check the type of x with console.log(typeof x) it shows as object. why?
console.log(typeof x)
In JS, arrays are objects.
If you need to test whether a variable is an array:
if (x.constructor === Array) console.log('它是一个数组');
In JS, arrays are objects.
If you need to test whether a variable is an array: