-5

When I run this IIFE function in the console or using it in document, it doesn't work, per definition it's immediately invoked, so why it's not showing anything on the console?

(function(){ 
   console.log(8);
});
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 6
    That's a function expression, but it's not invoked, immediately or otherwise. Add `()` before the last semicolon. – Pointy Nov 19 '17 at 13:58
  • Related: [*What is the (function() { } )() construct in JavaScript?*](https://stackoverflow.com/questions/8228281/what-is-the-function-construct-in-javascript/8228308#8228308) – T.J. Crowder Nov 19 '17 at 14:04

1 Answers1

1

You missed the execution part.

(function(){ 
   console.log(8);
})(); // () needs to be added
Vipin Kumar
  • 6,441
  • 1
  • 19
  • 25