Skip to main content

Command Palette

Search for a command to run...

[JavaScript] Immediately Invoked Function Expressions (IIFE)

Published
•View as Markdown
[JavaScript] Immediately Invoked Function Expressions (IIFE)
const runOnce = function () {
  console.log('This will never run again');
};
runOnce();

// IIFE
(function () {
  console.log('This will never run again');
  const isPrivate = 23;
})();

(() => console.log('This will ALSO never run again'))();

{
  const isPrivate = 23;
  var notPrivate = 46;
}
// console.log(isPrivate);
console.log(notPrivate);

IIFE.PNG

JavaScript

Part 1 of 50

More from this blog

Jayden's Blog

166 posts