📜  js 中的 typeof - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:39.883000             🧑  作者: Mango

代码示例6
exports.is = (data) => {
const isArray = Array.isArray(data) && 'array'
const isObject = data == {} && 'object'
const isNull =  data == null && 'null'

const isGrouping =  isArray || isObject || isNull
const isCheck = !isGrouping ? typeof data : isGrouping

const isTypeData = ['number','string','array','symbol','object','undefined','null','function', 'boolean']
const isMatch = isTypeData.indexOf(isCheck)
const isResult = isTypeData[isMatch]
return isResult
}