4 ms·
I don't understand your contradiction to the parent poster. All JavaScript functions are closures, including anonymous functions that don't reference any lexica
by bjterry 13y ago
I don't understand your contradiction to the parent poster. All JavaScript functions are closures, including anonymous functions that don't reference any lexically-scoped variables, and even named functions at the top level, which close over the global environment[1]. Also, callback functions don't have to be anonymous functions, you can just as easily pass named functions.
1: http://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/ http://javascriptweblog.wordpress.com/2010/10/25/understandi...
- elbear 13y agoI know that confusing anonymous functions with closures is a common misconception. I also know that callback functions don't need to be anonymous, but a lot of the times they are, at least in the JavaScript code that I've seen. Thank you for the clarification that all JavaScript functions are closures though.