Created
May 5, 2017 11:57
-
-
Save MaraAlexa/1c252a95d9282597aa3c124c9815a724 to your computer and use it in GitHub Desktop.
ES6: replacing an IIFE (immediadly invoked function expression) with a block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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