- Global Scope
- Local Scope
var greeting='Welcome to blog';
(function(){
console.log(greeting); //Output: Welcome to blog
})();
consider above code greeting variable should be global scope, it can access inside the function,
(function(){var greeting = 'Welcome to blog'; console.log(greeting); //Output: Welcome to blog })();console.log(greeting); //Output:Reference-Error greeting not defined