Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The underscore.js source (http://documentcloud.github.com/underscore/) also serves as a great primer on the effective use of 'this'. My rule of thumb is to never rely on 'this' unless 1) the function is already bound to an object or 2) I have explicitly set the binding via bind, call or apply. When in doubt favor explicit argument passing.


In general, you can use explicit argument passing or closing over what you need. I tend to use closures to get information from my current scope to a callback, although that doesn't always work in heavily object-oriented code.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: