0

Sorry for my English. I am wondering whether it is possible to send one file to another file variable?

for example

oneFile.js

var a = true;

twoFile.js

if(a == true) {
alert("hellow");
}
  • 1
    possible duplicate of [Include a JavaScript file in another JavaScript file?](http://stackoverflow.com/questions/950087/include-a-javascript-file-in-another-javascript-file) – Jivings Feb 02 '15 at 12:06
  • include both the .js files in script tags mentioning source path inside html file so as to load the files.. – Rakesh_Kumar Feb 02 '15 at 12:07

2 Answers2

0

Well, if oneFile.js is loaded before twoFile.js, it will work. Though this exact scenario would be definitely bad practice.

By the way, jQuery works the exact same way, it defines $ in jquery.js, and then you can use it in your own script files.

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
0

meskobalazs explained very well, If these two files are in different page I think you can use HTML5 session/local storage

http://www.w3schools.com/html/html5_webstorage.asp

Gilson PJ
  • 3,443
  • 3
  • 32
  • 53