[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Splitting a JavaScript file

Posted on 2007-10-11
5
Medium Priority
?
169 Views
Last Modified: 2010-04-15
Is it possible to split up a JavaScript file into two files so that more than one person can work on that code base at the same time?  Both files will be referenced in the same page.  Both files also need to reference local variables.  Basically it behaves as one file or similar to a C# partial class.
0
Comment
Question by:brettr
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20060056
Since javascript doesnt follow oops i cant think of anything similar to a partial class in javascript. just use two javascript files. they would still be able to access the elements in the web page. what do u mean by referencing local variables?
0
 

Author Comment

by:brettr
ID: 20060295
"what do u mean by referencing local variables?"

If JS file1 has

var myvar;

declared at the top of its file, can JS file2 do something such as:

text = myvar;

and get the value of myvar?  In other words, does that state exist globally for both files?
0
 
LVL 21

Expert Comment

by:surajguptha
ID: 20060389
Yes it is possible to have a var in js1 and set it from js2
0
 

Author Comment

by:brettr
ID: 20060594
Why do you say "possible"?  Are there any special conditions that must be met or something?
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 2000 total points
ID: 20060611
No its very straightforward and is possible. I didnt mean anything by saying its possible :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question