IIFE to Block
1 min readAug 29, 2015
This post is a part of Starter to ES6
Immediately-Invoked Function Expression (IIFE) to block scope
Previously if you wanted to isolate variables from global scope you were using IIFE, but in ES6 you can isolate variables in the new block scope { … }
IIFE
(function () { // open IIFE var tmp = ···; ··· }()); // close IIFE console.log(tmp); // ReferenceError
to block
{ // open block let tmp = ···; ··· } // close block console.log(tmp); // ReferenceError