Wednesday, April 6th, 2016

TL;DR: In ES6, an IIFE is implemented as follows:

Unlike ES5, which is syntactically less opinionated, in ES6, when using an IIFE, parenthetical order matters.

For instance, in ES5 an IIFE could be written either as:


As can be seen in the above examples, in ES5 one could either wrap and invoke a function expression in parentheses, or wrap the function expression in parentheses and invoke the function outside of the parentheses.

However, in ES6, the former throws an exception, thus, one can not use:

But rather, the invocation must be made outside of the parentheses as follows:

As an aside for those who are curious, the syntax requirements are specific to ES6 and not a by-product of any particular transpilers (i.e. Babel, Traceur, etc.).

Tags: , , ,

{ 1 comment to read ... please submit second! }

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

{ 0 Pingbacks/Trackbacks }