HackerNoon Mobile

Better reading experience on the app
A Closer Look at Immediately Invoked Function Expressions (IIFE) in JavaScriptby@smpnjn

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

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

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

@smpnjn

Johnny Simpson


Receive Stories from @smpnjn

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!