on-internet
← Community

Javascript: difference between using an IIFE and a block statement

Stack Overflow ·

IIFE are mainly used to encapsulate scope (function () { let myVar = 10; // not global // ... }()); but why not just use a block statement? { let myVar = 10; // also not global // ... } are there other benefits for using IIFE further than scope encapsulation?

Comments

Sign in or sign up to comment and upvote.

No comments yet.