I want to boolean to come out of this expression
(task === undefined);
where task is arbitrary and doesn’t appear in the code at all.
However, when I run this in rhino, I get a reference Error. I WANT TRUE
Why don’t I get true?
I want to check if a particular variable has been defined. How do I do it then if this doesn’t work?
Use this:
When you use
(task === undefined), Javascript needs to find the value oftaskto see if it is the same asundefined, but it can’t look up the name because it doesn’t exist, giving you the reference error.typeofis special in that it can safely return the type of a name that doesn’t exist.