The universal namespace
JavaScript, by default, adds all our classes and functions under a window namespace. The window namespace is like a universal namespace that contains all the functions, classes, and events that are associated with the current window. These functions, classes, and events are accessible everywhere in the web application. Now, having our functions and classes under the window namespace may not sound bad considering we can access them from everywhere, but if we are building a fairly large application, this quickly turns into a problem.
Having all our functions and classes in a universal namespace has one major problem: name conflict. So, for example, if we create a getData function and, then, someone else in our team also ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access