re: The Fine Art of the Webpack 2 Config VIEW POST

VIEW FULL DISCUSSION

Nitpick:

Does it seem strange to anyone else that the function needs to be wrapped in () like (functionGoesHere) for the self-executing to work?

In your example, it doesn't, because the context is already an expression.

This works fine:

const x = { y: function() { return 'z' }() }
console.log(x.y) // z

But this doesn't and the parens are required:

function() {
  console.log('a')
}()

Using them in your example is a convention. See also eslint.org/docs/rules/wrap-iife

code of conduct - report abuse