Global Variables in Javascript
TIL that global variables are automatically (magically?) set on window in javascript.
Example:
<script>
global_id = 4;
</script>
Is equivalent to:
<script>
window.global_id = 4;
</script>
I also learned that the javascript “this” keyword, when used outside of a closure, also refers to window. Neat!
Comments