0

An interesting question pop into my head and I couldn't find an answer, so I tried to ask you guys, to hear your thoughts about it!

Global variables that declared by var keyword stored as properties to the window object.

Example

var foo = "foobar";
window.foo === foo;

This code would return true because the foo Global Variable has become a property to the window object.

Well, the interesting part here is that:

let foo = "foobar"; // Or `const` it doesn't matter
window.foo === foo;

That code above would return false.

Shortly

I wonder; Where JavaScript store the Global Variables that declared by let and const?

Elharony
  • 886
  • 8
  • 18

0 Answers0