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.
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.
(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.