Re:JavaScript Programming Patterns
by monos on Tuesday October 06, 2009 @09:26AM
(#864046)
sorry, but why would carry the extra _obj around? why not simple do it like in my example above?
[ Parent
| on HN ]
Re:JavaScript Programming Patterns
by thegrossman on Tuesday October 06, 2009 @10:42AM
(#864220)
That works, too!
The reason I like using _obj is because "this" is notoriously hard to work with in JS. If, inside foo(), you have an iterator that you pass a function to, "this" takes on a different meaning inside that function.
Some people are really good at working out what "this" refers to, but I'm not. So I assign the main object to _obj just to be safe.