Namespace pattern

» Glossary » Namespace pattern

In JavaScript, it's known as the Namespace pattern, the practice of isolating code by wrapping it into an object/function:

var MyApp = {};
MyApp.doSomething = function( param ) { ... };

The benefits of doing so are that the global namespace is only polluted with one variable (MyApp), and our code is isolated from it.

See also: