Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it?
Quiz · JavaScript
Medium
3 min
javascript
Every script has access to the global scope, and if everyone uses the global namespace to define their variables, collisions will likely occur. Use the module pattern (IIFEs) to encapsulate your variables within a local namespace.
Adapted from the Front End Interview Handbook by Yangshun Tay and contributors (MIT License). Source
Spotted a mistake or a rights concern? Report an issue