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