Immediately-invoked function expression (IIFE)

The Immediately-Invoked Function Expression or IIFE for short is pretty self explanatory: it executes immediately after it's created.
It is not related to any event handler such as document.ready.
The first part (function(){...}) turns the code within into an function, and the parentheses at the end (); calls that function. IIFE has all the characteristics of any other functions regarding scopes.

(function(){ // do something })();

Result Box
  • html
  • css
  • js