r/javascript • u/talJoffe • Feb 09 '20
“Hoisting” doesn’t really exist in JavaScript! 😱 according to ECMAScript
https://medium.com/nmc-techblog/what-is-hoisting-in-javascript-bf73980d9dac1
u/agentgreen420 Feb 10 '20
This is idiotic. Why would code be literally moved around?
0
u/talJoffe Feb 10 '20
from w3school (just an example it is like this in most places):
"Hoisting is JavaScript's default behavior of moving declarations to the top."
https://www.w3schools.com/js/js_hoisting.asp1
u/mcaruso Feb 10 '20
I mean, it's not like a W3Schools tutorial is going to be talking about compile phases and execution phases. The description is just a conceptual one, and works fine as such.
2
u/talJoffe Feb 10 '20
You are right and many developers don't know that and take it literally.
This is similar to other parts of Javascript like "scope" and "this" in that it is simple if you know it but many developers don't
3
u/MoTTs_ Feb 10 '20 edited Feb 11 '20
The title is perhaps a little click-baity, but I liked the author's "let's dig into the spec and learn what this really is" approach.
2
5
u/jets-fool Feb 09 '20
an entire article about semantics.