Let's say that I have two files that are in separate directories:
/folder1/first.js
/folder1/folder2/second.js
first.js contains a variable called newName. Would it be possible to access it in second.js? (and how)?
EDIT: The HTML file is located in the same directory as first.js.
Assuming you are just linking static HTML files with <script> tags, then they will share their global scope. In other words: yes, second.js will be able to access the top-level variables from first.js, assuming they were liked in that order. Directories have no bearing on the behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With