Hacker News new | past | comments | ask | show | jobs | submit login

"Until you realize that he wants you to start every line that starts with [(+/-,.* with a semicolon."

Good point, that isn't immediately clear.

To help me understand, the article listed an example where a line started with a [, what are situations where a line is likely to start with (+/-,.* ?




The immediate-function pattern starts with an open paren.

(function () {

}());


So you do this to nest temporary variables in another lexical scope inside of another outer function? (as vars have function scope rather than block scope)

I'm not sure I would use this much, though now that you have pointed it out, I had better well be able to read it when somebody else does it to me. Thanks, I think.


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-Patte...

https://github.com/jquery/jquery/blob/master/src/ajax.js


Odd. 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.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: