-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.
  • 73,243
  • 15
  • 104
  • 123
User314159
  • 7,733
  • 9
  • 39
  • 63
  • [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,283
  • 1
  • 18
  • 24