-3

What's the purpose of doing

(function(){
   console.log('holla at world');
})();

instead of

console.log('holla at world');

Is there an example where something has to be done using the first case.

Dan D.
  • 70,581
  • 13
  • 96
  • 116
User314159
  • 7,065
  • 9
  • 36
  • 60
  • [Immediately-invoked function expression](https://en.wikipedia.org/wiki/Immediately-invoked_function_expression) – CD.. Dec 11 '15 at 08:52

1 Answers1

0
(function(){
   console.log('holla at world');
})() 

It's Immediately invoking function expression(IIFE) , the point of using IIFE's is to stop global scope pollution.

Ramanlfc
  • 8,108
  • 1
  • 16
  • 24