aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Regardubg reusing .js file in my java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Regardubg reusing .js file in my java script" Watch "Regardubg reusing .js file in my java script" New topic
Author

Regardubg reusing .js file in my java script

Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
If a variable exists all JavaScript does is override the previous variable.

Eric
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Oh! java script overrides previous variable, not redeclares the variable..Understood. Thank you Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regardubg reusing .js file in my java script