In a lot of ways it comes down to people not understanding the difference between the script parsing and execution, which are two separate steps.
Really though I think the root of the confusion comes from the same derpy nonsense that oft makes C a mess, and that's the lack of forward declaration as mandatory. ALL of these confusions and issues people have in their code -- even the stuff people are throwing the crap let/const rubbish at -- could have been avoided from day one if we were REQUIRED to declare all variables used inside a function at the start of the function in a single VAR statement.
You know, like Pascal, Modula, Ada, and other languages that provide some measure of scope security, inherent variable cross-reference, etc, etc.
But what do I know? I think Kernigan can go suck an egg: "C is not my favorite programming language."
This derpy halwit ability to just declare a new variable ANYWHERE! 100% hurr-durrz. Especially from a low-level programming point of view.