Self executive functions

(function(){
  console.log('Hello World!');
})();

The two brackets at last cause everything contained in the preceding parentheses to be executed immediately. What’s useful here is that JavaScript has function level scoping. All variables and functions defined within the anonymous function aren’t available to the code outside of it, effectively using closure to seal itself from the outside world.

results matching ""

    No results matching ""