const isType = function (type) {
return function (val){
return type === Object.prototype.toString.call(val).slice(8, -1)
}
}
const isType = type => val => type === Object.prototype.toString.call(val).slice(8, -1) // 箭头函数写法
const isArray = isType('Array') // 是否数组
const isObject = isType('Object') // 是否对象
const isNull = isType('Null') // 是否null
const isUndefined = isType('Undefined') // 是否undefined
const isFunction = isType('Function') // 是否函数
const isRegExp = isType('RegExp') // 是否正则
const isString = isType('String') // 是否字符串
const isNumber = isType('Number') // 是否数字
const isDate = isType('Date') // 是否日期
(函数柯里化)判断数据类型
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。