Redeclaring a javascript variable

It’s nothing more than a reminder that if you do this:

var x=5;
var x;
alert(x);

Result will be 5.

If you re-declare variable in some other languages for example – result will be undefined, or NaN, but not in javascript.

Leave a Comment