forked from WangJia-mm/JavaScript201708
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1-1.js
More file actions
29 lines (28 loc) · 819 Bytes
/
Copy path1-1.js
File metadata and controls
29 lines (28 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
~function () {
var obj = {
isNumber: 'Number',
isString: 'String',
isBoolean: 'Boolean',
isNull: 'Null',
isUndefined: 'Undefined',
isPlanObject: 'Object',
isArray: 'Array',
isRegExp: 'RegExp',
isDate: 'Date',
isFunction: 'Function'
};
var checkType = {};
for (var key in obj) {
if (!obj.hasOwnProperty(key)) continue;
checkType[key] = (function () {
var className = obj[key];
return function (val) {
var reg = new RegExp('\\[object ' + className + '\\]');
return reg.test(Object.prototype.toString.call(val));
}
})();
}
window.checkType = checkType;
}();
// console.log(checkType.isPlanObject({}));
console.log(checkType);