~function (_){
let types = "Array Object String Date Regexp Function Boolean Number Null Undefined".split(' ')
function type() {
return Object.prototype.toString.call(this).slice(8,-1)
}
for (let i=types.length; i--; i<0) {
_['is'+ types[i]] = (function (ele){
return function (elem) {
console.log(elem)
return type.call(elem) === ele
}
})(types[i])
}
return _
}(_={})
console.log(_)
console.log(_.isObject({})) // true
网友评论