While browsing, I frequently take a look at the source code of webpage to check how certain things have been realized.
One thing I frequently see is stuff like: window.myApp.apiKey = 12345;
or window.myApp.welcomeMsg = "Hello there!";
I always was under the impression that it's bad practice to attach properties to the window object (like explained in this accepted answer), but it looks like myApp
is used as a kind of namespace & since it's often the brand name, it's unlikely to clash with anything.
Still – how is it okay to do it this way, are there any indicators for that? (i.e. when I know no 3rd libraries will be used in the project, which can change quickly in real life).