Day 2 : Global Pollution - JavaScript


 

 

Var for declaration :

                    

·         In JavaScript, first we declare the variable then initialize it.

·         The compiler knows the datatype only after initialization.

 

Global Pollution :

·         Before global pollution we have to understand about the reference error.

·         If variable is not declared in respected scope then compiler shows the reference error.

·         Example of reference error:

 

  • Output:


  •  If we don’t give var keyword to variable then it will access the value globally i.e called as global pollution.
  • Var respects scope, without var keyword variables are global.
  •  Example of global pollution:

  • Output:

 


  Thank You!!!


For more understanding watch below video👇

Angular


JavaScript Day 1 : Day 1

Comments

Popular posts from this blog

Day 3 : JavaScript

SQL Concepts-1

ASP .NET Session Management