Skip to content

Instantly share code, notes, and snippets.

@henryspivey
Forked from prof3ssorSt3v3/9-hoist.js
Last active October 30, 2019 21:03
Show Gist options
  • Select an option

  • Save henryspivey/c02a2e1ddde41c20b2c7fda3b4688fa9 to your computer and use it in GitHub Desktop.

Select an option

Save henryspivey/c02a2e1ddde41c20b2c7fda3b4688fa9 to your computer and use it in GitHub Desktop.
//var hoisting vs let hoisting
//WHAT will be the output from this code and why?
function f() {
console.log('var', area); // undefined
if(area !== 'undefined) {
console.log('var', area);
}
console.log('let', name); // reference error
try {
console.log('let', name);
} catch(err) {
console.log(err)
}
let name = 'Bert';
var area = 'Geology';
}
f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment