1. ~function () {
    2. const ENUM_KEY = {
    3. isNumber: "Number",
    4. isString: "String",
    5. isBoolean: "Boolean",
    6. isNull: "Null",
    7. isUndefined: "Undefined",
    8. isObject: "Object",
    9. isArray: "Array",
    10. isFunction: "Function",
    11. isReg: "RegExp",
    12. isDate: "Date"
    13. }
    14. function isType (type) { // type String
    15. const reg = new RegExp("^\\[object " +type+ "\\]$", "i");
    16. return (value) => {
    17. return reg.test(Object.prototype.toString.call(value));
    18. };
    19. };
    20. const check = {};
    21. for (const key in ENUM_KEY) {
    22. if (ENUM_KEY.hasOwnProperty(key)) {
    23. check[key] = isType(ENUM_KEY[key]);
    24. }
    25. }
    26. window.$t = check;
    27. }();
    28. $t.isObject({}) // true