检验是否是数组
let a = [1,2,3]
Object.prototype.toString.call(a) === '[object Array]';//true
检验是否是函数
let b = function () {};
Object.prototype.toString.call(b) === '[object Function]';//true
检验是否是数字
let c = 1;
Object.prototype.toString.call(c) === '[object Number]';//true
判断数组方法 Array.isArray() //在ES5开始支持
let a = [1,2,3]
Array.isArray(a);//true
网友评论