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
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nitpick:
In your example, it doesn't, because the context is already an expression.
This works fine:
But this doesn't and the parens are required:
Using them in your example is a convention. See also eslint.org/docs/rules/wrap-iife