js 判断对象和数组

let arr = [];

let obj = {};

Object.prototype.toString.call(arr) === '[object Object]'   //判断对象  返回true

Object.prototype.toString.call(obj) === '[object Array]'    //判断数组   返回true

posted @ 2020-06-04 11:29  PromiseOne  阅读(335)  评论(0编辑  收藏  举报