Yansky said:
If I have the following code:
var abc;
if(!abc){
alert('test');
}
Does "if(!abc)" check to see if the variable is null or does it check
to see if the variable exists at all?
In that code, abc always exists.
Anyway ! EXPRESSION:
Throws a reference error if the EXPRESSION resolves to a property of
which the base object can't be determined; loosly: an undeclared
variable. (As far as I can tell. This part of the specs has some pretty
deep implied consequences).
If the expression does resolve to a value (which includes declared but
not explicitly initialized global variables and never-before used
properties of explicit objects, which will be undefined) it will first
convert the EXPRESSION to a boolean and then return the inverse.
The standard ToBoolean conversion is:
undefined -> false
null -> false
boolean -> boolean
numbers 0, -0, NaN -> false
other numbers -> true
empty string -> false
other string -> true
object -> true
See ecma 262 3rd edition, section 9.2.