• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regardubg reusing .js file in my java script

 
Shashi Kala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I am having doubt here in java script.

I have jsp file with some java script. Here I am reusing some other .js file say util.js . In util.js I have declared a variable as shown below.

var name = "";

In my jsp file I wrote my java script, Here also I declared same variable(var name = "" . But it is working fine without showing any java script error.

Why like this..Actually what is my doubt means..

In case of jsps, if we include some other jsp in our jsp, redeclaration of same variable results us an error right..But in java script it is not working like this..So what is the difference.Can anybody clear out my doubt?

Best Regards,

Shashi kala
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a variable exists all JavaScript does is override the previous variable.

Eric
 
Shashi Kala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! java script overrides previous variable, not redeclares the variable..Understood. Thank you Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic