Ajay Yadav
Ajay Yadav

@ATechAjay

9 Tweets Sep 21, 2022
πŸ’‘ IIFE: Immediately Invoked Function Expression
🧡...
πŸ’‘IIFE?
❍ IIFE stands for Immediately Invoked Function Expression.
❍ IIFE is an anonymous JavaScript function that executes as soon as it's defined.
❍ It is also known as a "self-executing anonymous function".
❍ Suppose you do not want to store a function in a window object or you do not want to use a process once used.
❍ So we can use "Immediately Invoked Function Expression" to achieve this goal.
πŸ’‘ Syntax of IIFE:
❍ anonymousFunction: we have to define an anonymous function inside the parentheses(grouping operator).
❍ invoking: after defining an anonymous function, we can call/invoke that function using the grouping operator (parentheses).
😍 Example:
❍ I've created an anonymous function and I want to execute this function using IIFE.
❍ So, we have to wrap this function into parentheses(grouping operator)
❍ We have to wrap the anonymous function into parentheses like this. πŸ‘‡
πŸ’‘ Now it's a function. So we can quickly call/run/invoke this function as a regular function using parentheses.
❍ I called this function and also passed 2 arguments to the function, which are 10 and 20.
❍ And the result is 30.
πŸ”” But we can also implement this function expression using an arrow function.
πŸ’‘ IIFE with an arrow function expression.
That's all for now, we will meet in the next thread😍
πŸ”” Follow Me @ATechAjay
For:
🌐 Web Development
✨ JavaScript
πŸ“ Writing Skill
πŸ”₯ Motivation
πŸ’Ή Growth
β›” But Not For Only Resources & Shitpost 😁
Thank you so much for staying to the end of this threadπŸ’š

Loading suggestions...