4 ms·
Most javascript modules are defined inside a similar pattern, I'm surprised you haven't seen it yet. http://www.adequatelygood.com/2010/3/JavaScript-Module-Pat
by sharkbrainguy 16y ago
Most javascript modules are defined inside a similar pattern, I'm surprised you haven't seen it yet.
http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth http://www.adequatelygood.com/2010/3/JavaScript-Module-Patte...
https://github.com/jquery/jquery/blob/master/src/ajax.js https://github.com/jquery/jquery/blob/master/src/ajax.js
- Roboprog 16y agoOdd. I've usually just returned or assigned the function def without the outer parens. For some reason, the outer parens syntax looked like it was defining an anonymous function, and also calling it immediately, which is of course not what that turns out to do. It's an interesting language, but I'm still at the dabbling stage. I'd like to think I'm past the voodoo stage (onfoo="whack()" attributes that call in-page functions with global variables), but maybe not.