A Closer Look at Immediately Invoked Function Expressions (IIFE) in JavaScriptby@smpnjn
209 reads

A Closer Look at Immediately Invoked Function Expressions (IIFE) in JavaScript

by Johnny Simpson3mNovember 6th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

IIFEs give us an easy way to isolate variables within a function, and not globally - after which we can easily run the function immediately. Immediately invoked function expressions, or IIFE, are functions that are run as soon as you define the function. They are also useful for running async functions when a top level `await` is not available. The defensive semi-colon is added to the start of IIFE code to avoid a weird issue where the previous line doesn't have a semi-Colon, the function's last line will be used as the function name.
featured image - A Closer Look at Immediately Invoked Function Expressions (IIFE) in JavaScript
Johnny Simpson HackerNoon profile picture
Johnny Simpson

Johnny Simpson

@smpnjn

Product, Engineering, Web

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S
EXPERTISE AND PLACE ON THE INTERNET.

Share Your Thoughts

About Author

Johnny Simpson HackerNoon profile picture
Johnny Simpson@smpnjn
Product, Engineering, Web

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
L O A D I N G
. . . comments & more!