Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  144] [ 3]  / answers: 1 / hits: 31263  / 13 Years ago, sun, july 31, 2011, 12:00:00

In this tutorial there is written:



If you redeclare a JavaScript variable, it will not lose its value.



Why should I redeclare a variable? Is it practical in some situations?



thank you


More From » variables

 Answers
41

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.


[#90903] Friday, July 29, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janettejordynm

Total Points: 550
Total Questions: 94
Total Answers: 98

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;