Last active
January 19, 2019 20:43
-
-
Save Maccauhuru/7e9cc45b886dea35ee19d8a3333d8918 to your computer and use it in GitHub Desktop.
IIFE Variable Assignment Example
This file contains hidden or 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 variable holds/stores a function that prints 'welcome to the jungle' | |
const welcomeMessageVariable = function (){ | |
return "Welcome to the jungle!"; | |
}; | |
//we will invoke our first variable here below | |
welcomeMessageVariable(); // Welcome to the jungle! | |
//This second variable holds/stores the value 'welcome to the jungle' | |
const welcomeMessageIIFE = (function(){ | |
return "Welcome to the jungle!"; | |
})(); | |
//we will invoke it below. *Note how we do not need the '()' | |
welcomeMessageIIFE; // Welcome to the jungle! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment