Skip to content

Instantly share code, notes, and snippets.

@Maccauhuru
Last active January 19, 2019 20:43
Show Gist options
  • Save Maccauhuru/7e9cc45b886dea35ee19d8a3333d8918 to your computer and use it in GitHub Desktop.
Save Maccauhuru/7e9cc45b886dea35ee19d8a3333d8918 to your computer and use it in GitHub Desktop.
IIFE Variable Assignment Example
//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