标签:function OLE 函数对象 ase reac tostring number func 数据类型
var type = function (o){
var s = Object.prototype.toString.call(o);
return s.match(/\[object (.*?)\]/)[1].toLowerCase();
};
[‘Null‘,
‘Undefined‘,
‘Object‘,
‘Array‘,
‘String‘,
‘Number‘,
‘Boolean‘,
‘Function‘,
‘RegExp‘
].forEach(function (t) {
type[‘is‘ + t] = function (o) {
return type(o) === t.toLowerCase();
};
}); //给type函数对象封装各个判断的方法
type.isObject({}) // true
type.isNumber(NaN) // true
type.isRegExp(/abc/) // true
标签:function OLE 函数对象 ase reac tostring number func 数据类型
原文地址:https://www.cnblogs.com/sidianok/p/13224625.html