This Week in JavaScript - 21 March 2016

Excellent stuff.

With the IIFE article, I’m with Douglas Crockford who prefers to have the invoking parenthesis inside of the wrapper parenthesis.

(function () {
    ...
}());

Because, the above makes it clearer that the purpose of the wrapping parenthesis is just to allow the function to be invoked.

The alternative where the invoking parenthesis are hanging off the end, Crockford claims looks like dog balls, and I’m with him on that one:

(function () {
    ...
})();

The above code raises more questions, such as why are the wrapping parenthesis being invoked? And, it’s a change of structure from how all other functions are normally invoked.

Crockford clarifies this in this video excerpt (video 1m 37s)

Dog balls indeed.

1 Like