Why does this work in a Node.js
console (tested in 4.1.1 and 5.3.0) but doesn\'t work in the browser (tested in Chrome)? This code block should create and invok
I asked a question like this:
@getify I’ve this question: to produce an #IIFE pattern we use parans around a function declaration to transform it into a function expression and then invoke it. Now in arrow function IIFEs, why do we need parans?! Isn’t the arrow function already an expression by default?!
and this is the Kyle Simpson's answer:
an arrow function is an expr, but we need surrounding parens b/c of "operator precedence" (sorta), so that the final parens to invoke the arrow-IIFE apply to the entire function and not to just the last token of its body.
x => console.log(x)(4)
vs
(x => console.log(x))(4)
— getify (@getify) June 12, 2020