1

I have file1.js :

View = function(){

var privateprop;

this.method=function(){
...
}

} 

and file 2 like this:

subView = new function(){
 var privateProp2;

this.method2= function(){

}

}

I want an instance of subView in file1.js like:

var fileObj = new subView();
fileObj.method2();

can I access this directly ? I mean can I access classes(actually functions) defined in file2.js in file1.js directly? Dont we need any imports in Javascript?

ALBI
  • 721
  • 2
  • 16
  • 34
  • Have you included both of these files as a ` – h2ooooooo Dec 02 '13 at 11:25
  • What you think have you tried? ` ` working? – Just code Dec 02 '13 at 11:25
  • 1
    Refer this http://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file – goutham2027 Dec 02 '13 at 11:26

1 Answers1

0

Assuming, you want to use your JS in HTML: just include both files in your HTML file like this:

<script src="file2.js"></script> 
<script src="file1.js"></script> 
sebastian_oe
  • 7,186
  • 2
  • 18
  • 20