1.判断对象是否为数组
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script type="text/javascript"> const list = ['1','3','5']; const data = Array.isArray(list); if(data){ console.log('是数组',data) // true }else{ console.log('不是数组',data) // false } </script> </body> </html>
转载于:https://my.oschina.net/u/3946362/blog/3100904