Search

10/26/2009

jslint - Require parens around immediate invocations

JavaScript: immediate function invocation syntax

ere is a JSLint option, one of The Good Parts in fact, that "[requires] parens around immediate invocations," meaning that the construction

(function () {

// ...

})();

would instead need to be written as

(function () {

// ...

}());


My question is this -- can anyone explain why this second form might be considered better? Is it more resilient? Less error-prone? What advantage does it have over the first form?
From Douglass Crockfords own PPT on the issue: (search for "require parens")

Makes more clearly the distinction between function values and the values of functions.

So, basically, he feels it makes more clear the distinction between function values, and the values of functions. So, it's an stylistic matter, not really a substantive difference in the code itself.

沒有留言: