I'm trying to understand better how to determine if a variable is undefined and I get mixed results, hopfuly someone can make it clearer.
This is the example:
What I expect is none_exisiting_variable to result 'false' for the isDefined check.
I'm trying to understand better how to determine if a variable is undefined and I get mixed results, hopfuly someone can make it clearer.
This is the example:
What I expect is none_exisiting_variable to result 'false' for the isDefined check.
That's the difference between
undefined
value, or a variable whose value is undefined
(that's what can check angular.isDefined
)To check a variable is not defined, do
if (typeof myvariable === "undefined") {
var foo = 'foo';
angular.isDefined(foo) // true;
angular.isDefined(bar) // false
var bar = 'bar';