DEV Community

Discussion on: Javascript: Hoisting

Collapse
z00md profile image
z00md

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 Author

Yes, well said! Thank you for this.