Thursday, April 26, 2018

Global Object (Window)

Global object is nothing but referring "window" only. The same will be called in node js as "global". For other frameworks it may have different name.

What it will do ?

It will provides you to access the built-in functions and values and provides access to the global Function Declarations and var variables.

Note: let and const is different from this. Declaring with var only we can consider as global.



var phrase = "Hello Test";

function sayHi() {
  alert(phrase);
}

// can read from window
alert( window.phrase ); // Hello Test
alert( window.sayHi ); // function sayHi() { alert(phrase); }


No comments:

Post a Comment