DEV Community

Discussion on: Javascript: Hoisting

Collapse
 
amt8u profile image
amt8u

Just to add clarity - The compiler executes the script in 2 phases. In the first one it allocates and defines all variables it finds including var, let and even const. In the 2nd phase it runs the code line by line thereby giving a feeling that declarations were moved to top. There is no such script alteration at runtime.

Collapse
 
jeanetterosario profile image
Jeanette Rosario

Yes, well said! Thank you for this.