referencing desired objects in namespaced functions

Posted by RyOnLife on Stack Overflow See other posts from Stack Overflow or by RyOnLife
Published on 2010-04-08T18:02:35Z Indexed on 2010/04/08 18:23 UTC
Read the original article Hit count: 111

Filed under:
|
|

I'm having trouble referencing the desired object when I've namespaced functions.

No problems here:

obj.test = function() {
  // this == obj
}

But I'm getting tripped up when I namespace:

obj.namespace.test = function() {
  // this == namespace
}

In the latter example, I know this references namespace, but I want to reference obj. How can I do it?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about this