Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap

What is an IIFE? IIFE is an acronym originally coined by Ben Alman that stands for "Immediately Invoked Function Expression". This tutorial will give multiple examples of IIFEs so you can identify IIFEs and know the reasons for using IIFEs.

Subscribe https://bit.ly/3nGHmNn

JavaScript for Beginners: Full Course (8 hours): https://youtu.be/EfAl9bwzVZk

Javascript Recursion Tutorial: https://youtu.be/Q0alTGQ-lXk
Javascript Ternary Tutorial: https://youtu.be/ib8MHSMwtYg
Javascript Scope Tutorial: https://youtu.be/_E96W6ivHng
Javascipt Closure Tutorial: https://youtu.be/1S8SBDhA7HA

What is an IIFE? | Javascript IIFE Functions Explained

(00:00) Intro
(0:16) IIFE: Immediately Invoked Function Expression
(3:06) IIFE Reason 1: Avoid Polluting the Global Object Namespace
(5:42) IIFE Reason 2: Create Private Variables & Methods with Closures
Reason 3: Namespaces
(8:50) IIFE Reason 3a: The Module Pattern
(11:06) IIFE Reason 3b: The Revealing Pattern
(12:36) IIFE Reason 3c: Injecting a Namespace

Corrections:
(1:30) The example has the default parameter in the wrong place. It should look like this function myIIFE(num = 0)


References:
Ben Alman Blog Post: http://benalman.com/news/2010/11/immediately-invoked-function-expression/
Flavio Copes Blog Post: https://flaviocopes.com/javascript-iife/
MDN Web Docs: https://developer.mozilla.org/en-US/docs/Glossary/IIFE

Follow Me:
Twitter: https://twitter.com/yesdavidgray
LinkedIn: https://www.linkedin.com/in/davidagray/
Blog: https://yesdavidgray.com
Reddit: https://www.reddit.com/user/DaveOnEleven

Was this tutorial about Javascript IIFE Function Expressions helpful? If so, please share. Let me know your thoughts in the comments.

#javascript #IIFE #tutorial