3 ms·
Answer for number 7 : undefined global variable. I had to look this up, because it's so far outside of even moderately normal practices I'd not encountered it.
by mjevans 5y ago
Answer for number 7 : undefined global variable.
I had to look this up, because it's so far outside of even moderately normal practices I'd not encountered it.
https://stackoverflow.com/questions/30469755/why-a-variable-defined-global-is-undefined https://stackoverflow.com/questions/30469755/why-a-variable-...
Hoisting. Within the function body the declaration of the variable, but not it's initialization, is (re-ordered) hoisted to the top of the function, much like old C. So the clobbered global definition happens at the function frame step rather than exactly where a sane programmer would expect such insane code to perform it.
- TheCycoONE 5y agoYeah, that was a quirk fixed by let. No reason to use var anymore.