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
var name is not defined
alert(a);
Here a is not defined.
a
alert(a); var a=10;
Here a is undefined because javascript engine convert this code to
javascript
var a; alert(a); // that's why `a` is defined here a=10;