Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 10:33
Show Gist options
  • Save iamsaief/6e2786fe2758e197d2b72cf8492dbf85 to your computer and use it in GitHub Desktop.
Save iamsaief/6e2786fe2758e197d2b72cf8492dbf85 to your computer and use it in GitHub Desktop.
/* 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