Window and this & scope :
- Whenever you create any JS file, then automatically attached to the window object..
- global environment context, variables and functions are present in the window object..
- window === this ---> true
Accessing the variables :
console.log(Window.variablename)
console.log(variablename)
console.log(this.variablename)
- JavaScript is a loosely typed or weakly typed language. So it means you can change the type also.
Example:
var v = 10;
console.log(v) // it will print 10
v = " shivaji";
console.log(v) // it will print shivaji
undefined vs not defined :
Undefined:
- It is a special keyword.
- Undefined is like a special placeholder that is kept inside the variables.
Not defined:
- accessing the variable or functions without declaring...
- Not defined is a reference error.