DEV Community

loading...

Discussion on: The last article you will ever need to read to understand hoisting in JavaScript

Collapse
aroman012 profile image
Alejandro Roman

Thank you for your explanation! I have struggled with this concept before.

Btw, in this sample code you provided:

var isNight = true
if(isNight) {
  let midnightSnack = "ice cream"
}
console.log(midnightSnack) // "ice cream"
Enter fullscreen mode Exit fullscreen mode

Perhaps you meant to say var midnightSnack instead of let midnightSnack?

Collapse
albert_hadacek profile image
Albert Hadacek Author

Ohh yeah, thanks, fixed