js判断是否为数组:原型上的 isArray() 方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div>js检测数组</div> <script> let a = [1, 2, 3] console.log(typeof a);//object // Array原型上的isArray()方法,返回一个布尔值 console.log(Array.isArray(a));//true;返回为true则是数组,返回为false则不是数组 </script> </body> </html>