How to pass two anonymous functions as arguments in CoffeScript?

I think the problem lies with using single line comments //. Single-line comments enclosed in /* .. */ seem to work fine. Here’s an equivalent example with something other than a comment. $(‘element’).hover( -> console.log(“first”) -> console.log(“second”) ) Or with comments using /* .. */. $(‘element’).hover( -> /* first */ -> /* second */ ) … Read more

JavaScript anonymous function immediate invocation/execution (expression vs. declaration) [duplicate]

The first two cases show function expressions, and can appear anywhere an expression like (1+1 or x*f(4)) would appear. Just like how 1+1, evaluates to 2, these expressions evaluate to a corresponding function. The third case is a function declation statement, and can appear anywhere you can have other statements (like an if or while … Read more

(…()) vs. (…)() in javascript closures [duplicate]

There’s no difference. Both are valid ways to get the JavaScript parser to treat your function as an expression instead of a declaration. Note that + and ! will also work, and are sometimes used by minifiers to save a character of size: +function() { var foo = ‘bar’; }(); !function() { var foo = … Read more