If you attempt to use a variable that does not exist and has not been declared, javascript will throw an error. var name is not defined
, and the script will sto
An undeclared variable does not exist in Javascript memory whereas a declared one does and can be set to undefined.
The difference is caused by Javascript design confusion. If a variable's value is undefined then it should be deleted. Indeed falsy values like 0, "", null, and undefined, are all basically meaningless and identical. A lot of time is wasted on them. They are all nothing and non existent. It is highly contradictory to have more than one type of nothing, or maybe to allow even one.
Therefore I think you should avoid explicitly using falsy values when programming altogether. I didn't find a case yet when they couldn't be eliminated by a better method, and programming is much nicer without them.