Created
August 22, 2020 10:33
-
-
Save iamsaief/6e2786fe2758e197d2b72cf8492dbf85 to your computer and use it in GitHub Desktop.
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
/* global/block scope */ | |
let result = 10; | |
function sum(x, y) { | |
let result = x + y; | |
console.log(result); // 35 | |
if (result > 10) { | |
var msg = "more than 10"; | |
console.log(msg); | |
} | |
console.log(msg); // outside scope, because of hoisting | |
} | |
sum(15, 20); | |
console.log(result); // 10 | |
/** | |
* Output: | |
35 | |
more than 10 | |
more than 10 | |
10 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment