/*
判断数据类型
@param s {Object Number Function Symbol} 所有数据类型
return string 类型
*/
const typeArr = ['Array', 'Undefined', 'Boolean', 'Number', 'Function', 'Symbol', 'Object', 'Date', 'Window', 'String', 'RegExp']
export const type = s => Object.prototype.toString.call(s).slice(8, -1).toLowerCase()
/*
isArray()
isUndefined()
isBoolean()
isNumber()
isFunction()
isSymbol()
isObject()
isDate()
isWindow()
isString()
isRegExp()
return 返回boolean类型
*/
typeArr.forEach((v) => {
type[`is${v}`] = s => { return type(s) === v.toLowerCase() }
})
网友评论