Skip to content

Commit 8dc13d7

Browse files
committed
[Refactor] make ES.TypeIsObject robust against future primitive types.
1 parent edd85e6 commit 8dc13d7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

es6-shim.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,14 @@
286286
},
287287

288288
TypeIsObject: function (x) {
289-
return x !== void 0 && x !== null && x !== true && x !== false &&
290-
typeof x !== 'string' && typeof x !== 'number' &&
291-
typeof x !== 'symbol';
289+
if (x === void 0 || x === null || x === true || x === false) {
290+
return false;
291+
}
292+
var type = typeof x;
293+
if (type === 'string' || type === 'number' || type === 'symbol') {
294+
return false;
295+
}
296+
return type === 'function' || type === 'object';
292297
},
293298

294299
ToObject: function (o, optMessage) {

0 commit comments

Comments
 (0)