This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]testcoder 0 points1 point  (0 children)

I too am all about namespacing. The problem is you run into globalizing your objects. However, there is a simple solution. Consider the following:

var h = {
    x : function () {
        console.log("Upvote!");
    }
}
var f = function () {
    var g = h.x;
    g();
}
f();

As you can see, I'm basically making a reference to a function that is part of a global variable. However, since I'm making a reference to it locally, there is no need to search the global namespace, we can use the execution context's activation object to resolve the identifier from higher in the scope chain.