Understand JS file execution and program boundaries
2nd-edIn JavaScript, every standalone .js file is treated as its own separate program. This has implications for error handling: a failure in one file (during parsing, compilation, or execution) does not necessarily prevent subsequent files from being processed.
Multiple files act as a single application by sharing state and functionality through the global scope.
If using ES6 modules (import statements or <script type=module>), each module is also treated as a separate program that inter-operates with others via the module-loading mechanism.