I asked a question about the undefined value in javascript a few days ago. (What is the best way to compare a value against 'undefined'?)
I conclude that it is a bad practice to do !== undefined
as undefined
can be set to 'another' value.
undefined='foo';
var b;
(b !== undefined) // true
I gave a quick look at the jquery code, I realized that in every part, the author use !== undefined
and not typeof var !== "undefined"
// Setting one attribute
if ( value !== undefined ) {
// Optionally, function values get executed if exec is true
exec = !pass && exec && jQuery.isFunction(value);
Is it a possible mistake? Even if I know that we should be crazy to reassign the value of undefined - for the most popular library I think it can cause some mistakes...
Who is in the right way?