I recently created a JavaScript code snippet that looks like this:
let var1 = 1;
window.var2 = 2;
After running the code in the Chrome console, I entered window
to inspect the global window object. Surprisingly, only the second variable appeared and the first one was nowhere to be found. This confused me as I expected both variables to be part of the global window object.
Could someone explain why this is happening?