Skip to content

Instantly share code, notes, and snippets.

@MaraAlexa
Created May 5, 2017 11:57
Show Gist options
  • Save MaraAlexa/1c252a95d9282597aa3c124c9815a724 to your computer and use it in GitHub Desktop.
Save MaraAlexa/1c252a95d9282597aa3c124c9815a724 to your computer and use it in GitHub Desktop.
ES6: replacing an IIFE (immediadly invoked function expression) with a block
// This is used when you want to make your program private (nothing leaks into the global scope of the window)
// BEFORE - using an IFY
(function(){
var name = 'mara';
console.log(name);
})();
// BETTER - using a block
{
const name = 'mara';
console.log(name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment