Hoisting in JavaScript allows you to access variables and functions before they are created.
This is misleading. They have been created otherwise they wouldn't be accessible. They're just created first before the function body executes. Hoisting is just a convenient mental model of what is going on, but it isn't actually what is going on. It is described well here
When I say βcreatedβ, Iβm referring to the end user looking at the source code. For them the creation has happened yet.
Internally the interpreter creates them before executing the function itself. No one is disagreeing with this.
And you are correct, it is a mental model that helps to understand this concept. The idea that the declarations are hoisted/bubbled up to the top of the source code. No one is trying to mislead.
Thanks for the feedback and linking to a more in depth article β₯οΈ
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is misleading. They have been created otherwise they wouldn't be accessible. They're just created first before the function body executes. Hoisting is just a convenient mental model of what is going on, but it isn't actually what is going on. It is described well here
When I say βcreatedβ, Iβm referring to the end user looking at the source code. For them the creation has happened yet.
Internally the interpreter creates them before executing the function itself. No one is disagreeing with this.
And you are correct, it is a mental model that helps to understand this concept. The idea that the declarations are hoisted/bubbled up to the top of the source code. No one is trying to mislead.
Thanks for the feedback and linking to a more in depth article β₯οΈ