I have a question: What´s the better approach to limit the scope in Javascript: Using a namespace like this:
var NAMESPACE = {};
NAMESPACE.foo = function() {
console.log('Hello');
}
NAMESPACE.foo();
or should I use the self-invoking function like this
(function() {
function foo() { console.log('Hello'); }
foo();
})();
Is it always good to have a namespace or can I omit it if I just use one big self-invoking function where I put all my stuff?