keyword namespace would replace window as a default global with another object until namespace is escaped.
namespace ENGINE;
Physics = {
applyForce: function(x, y) { ... },
processEntity: function(entity) { ... }
};
World = function() { ... };
namespace; /* escape namespace */
Global variables resolve to ENGINE.Physics
, ENGINE.World
If a variable is undefined for current namespace compiler looks for variable in a main global (window)
namespace ENGINE;
Math.cos(0.25); /* it's still window.Math.cos */
namespace;
Access variable from root scope:
namespace ENGINE;
Math = { }; /* overwrite */
window.Math /* still accessible as usual */
namespace;
Linking this thread https://gist.github.com/gre/fadd75d340f183444e44