标签:rip sni ret 判断 class cal ram java type
判断核心使用Object.prototype.toString,这种方式可以准确的判断数据类型。
/*** @param {any} target* @param {string} type* @return {boolean}*/function isType(target, type) {let targetType = Object.prototype.toString.call(target).slice(8, -1).toLowerCase()return targetType === type.toLowerCase()}
使用
isType([], ‘Array‘) // trueisType(/\d/, ‘RegExp‘) // trueisType(new Date(), ‘Date‘) // trueisType(function(){}, ‘Function‘) // trueisType(Symbol(1), ‘Symbol‘) // true
标签:rip sni ret 判断 class cal ram java type
原文地址:https://www.cnblogs.com/blhgys/p/13354324.html