Lambda functions in jQuery
Hi ! I'm new in jQuery, and seeing the examples I have noted that you always use lambda functions. Is there any reason for that? why you don't make something like this:
- $('something').click(on_click);
- ...
- function on_click(event)
- {
- ...
- }
I think is more clear than:
- $('something').click( function(event) {
- ...
- });
And we can edit and reuse the function easily, also if you are using an editor like Netbeans you can see all your functions in a list.
Even more, I think in some situations is faster a closure because we are not creating a new object every time we pass the function:
for (var i = 0; i < 1000; ++i) {
myObjects
[i].onMyEvent = function() {
// do something
};
}
Is there any reason for chosing lambda functions?
Thanks !