typeof something returns an object, not an array
P粉659378577
P粉659378577 2023-11-06 12:49:14
0
1
665

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粉659378577
P粉659378577

reply all(1)
P粉277305212

In JS, arrays are objects.

If you need to test whether a variable is an array:

if (x.constructor === Array)
   console.log('它是一个数组');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template