IIFE to Block

Bashar Ayyash
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

This post is a part of Starter to ES6

--

--

Bashar Ayyash

Front End Developer, I’m confident that Vue.js is as powerful as React, but way more flexible and a lot easier to learn