3 ms·
Not all global variables get assigned to the window object. For example: <script> let foo = "bar"; </script> <script> console.log(foo); // prints "ba
by Flimm 5y ago
Not all global variables get assigned to the window object. For example:
<script>
let foo = "bar";
</script>
<script>
console.log(foo); // prints "bar"
console.log(window.foo); // prints "undefined"
</script>
- mmazzarolo 5y agoHey! Was this a response to another comment? In the post I'm explaining why it's happening (and it's just purposely bad code to show a global instantiation example)