JS: Immediately Invoked Function Expression (IIFE)

By Xah Lee. Date: .

What is immediately invoked function expression

it means define a function expression and evaluate it immediately.

console.log((function f(x) { return x + 1; })(3)); // 4

can also be done by arrow function.

console.log(((x) => { return x + 1; })(3)); // 4