What\'s the best way of checking if an object property in JavaScript is undefined?
From lodash.js.
var undefined;
function isUndefined(value) {
return value === undefined;
}
It creates a local variable named undefined
which is initialized with the default value -- the real undefined
, then compares value
with the variable undefined
.
Update 9/9/2019
I found Lodash updated its implementation. See my issue and the code.
To be bullet-proof, simply use:
function isUndefined(value) {
return value === void 0;
}