- 自定义方法判断数据类型
const isType = type => target =>{
let stringType = Object.prototype.toString.call(target)
return `[object ${type}]` === stringType
}
const isArray = isType('Array'); //注意传入 type 参数时首字母大写
const isNull = isType('Null');
console.log(isArray([])); //true
isNull(null); //true