0

How can I restrict the global variable to that file only, ie not accessible to other script files, I have two script files like script1,js and script2,js

Surya
  • 41
  • 6
  • Global variables would be accessible to any script declared after it. `` Has Global `` Can See Global l You could try to include that script last to "block" other scripts from loading it in a sense, but the best method is to create abstract functions and pass around parameters. – NSTuttle Sep 20 '16 at 16:06

1 Answers1

0

You should capsule your code in each file, so you don´t pollute your windows object. Also, you can use "return" to get values from the other file, if needed.

Stefan Vilbrandt
  • 282
  • 3
  • 11