~function () {
const ENUM_KEY = {
isNumber: "Number",
isString: "String",
isBoolean: "Boolean",
isNull: "Null",
isUndefined: "Undefined",
isObject: "Object",
isArray: "Array",
isFunction: "Function",
isReg: "RegExp",
isDate: "Date"
}
function isType (type) { // type String
const reg = new RegExp("^\\[object " +type+ "\\]$", "i");
return (value) => {
return reg.test(Object.prototype.toString.call(value));
};
};
const check = {};
for (const key in ENUM_KEY) {
if (ENUM_KEY.hasOwnProperty(key)) {
check[key] = isType(ENUM_KEY[key]);
}
}
window.$t = check;
}();
$t.isObject({}) // true