Instantly share code, notes, and snippets.

@danielimmke danielimmke/hoisted_variables.js Secret
Last active Jul 11, 2018

What would you like to do?
console.log(hoistedVar); // "undefined" - hoisted declaration only
console.log(nonHoistedConst); // Throws an actual error in JS: nonHoistedConst is not defined
var hoistedVar = "Hoisted";
const nonHoistedConst = "Definitely not hoisted";
console.log(hoistedVar); // Actually displays the value of the variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment