Immediately Invoked Function Expression (IIFE) in JavaScript

The immediately Invoked Function Expression (IIFE) is quite handy in JavaScript. Almost all developers who have used JavaScript are more or less familiar with IIFE. This IIFE executes right away.

But the syntax is not always easy to do. In this post, we will share the correct syntax about IIFE.

    const username = (function () {
        const name = "Barry";
        return name;
    })();
    console.log(username);