Javascript Global Object via Window Object

Introduction

The web browsers implement it such that the window is the Global object's delegate.

All variables and functions declared in the global scope become properties on window.


let color = "red";

function sayColor() {
    console.log(window.color);
}

window.sayColor(); // "red" 



PreviousNext

Related