Created
August 4, 2019 13:20
-
-
Save hoangtranson/081a2e017dd335d47d71d306dd79d4a9 to your computer and use it in GitHub Desktop.
test hoisting on browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hoisted = "foo" in this; | |
console.log(`'foo' name ${hoisted ? "is" : "is not"} hoisted. typeof foo is ${typeof foo}`); | |
if (false) { | |
function foo(){ return 1; } | |
} | |
// In Chrome: | |
// 'foo' name is hoisted. typeof foo is undefined | |
// | |
// In Firefox: | |
// 'foo' name is hoisted. typeof foo is undefined | |
// | |
// In Edge: | |
// 'foo' name is not hoisted. typeof foo is undefined | |
// | |
// In Safari: | |
// 'foo' name is hoisted. typeof foo is function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment