3 ms·
Technically, all edge cases considered, `typeof` is the only fool-proof check, since you can't override the string constant `'undefined'` but the `undefined` id
by woogley 12y ago
Technically, all edge cases considered, `typeof` is the only fool-proof check, since you can't override the string constant `'undefined'` but the `undefined` identifier is fair game.
Here is one such edge case:
(function () {
var undefined = true;
return (function foo(x) {
return x === undefined;
}());
}()); // false
Language pedantry aside, browsers these days will freeze `window.undefined` so you'd have to shoot yourself in your own scope ;)
- tshadwell 12y agoif you're that determined to shoot yourself in the foot you might as well rebind valueOf