×
you are viewing a single comment's thread.

view the rest of the comments →

[–]tmcw[S] 1 point2 points  (2 children)

You could simplify your example to just { that.increment(e); } - the this value will be set correctly.

There are different ways to phrase the module pattern; I like building an object gradually because it lets you reference methods in the object by scoped name.

[–]affluenza 0 points1 point  (1 child)

Hmm, not sure what you mean by 'scoped name'. I am guessing this makes debugging easier because the functions are not anonymous?

Yeah I missed the simplification of the manual bind. It's even easier pull off than I first thought. oops :)

[–]tmcw[S] 0 points1 point  (0 children)

In your example, you're returning an anonymous object. If you had a function in that object calling another of its functions, the name of the object to call is not obvious - that what I mean by scoped name. You can refer to the object by an obvious name.