Skip to content

Instantly share code, notes, and snippets.

@aryak007
Created March 28, 2018 11:35
Show Gist options
  • Save aryak007/c0c9be44240fddcaa9f3bf1cbcddd763 to your computer and use it in GitHub Desktop.
Save aryak007/c0c9be44240fddcaa9f3bf1cbcddd763 to your computer and use it in GitHub Desktop.
var outerFunction = function(){
if(true){
var x = 5;
console.log(y); // ReferenceError: y not defined
}
var innerFunction = function() {
if(true){
var y = 7;
console.log(x); // x will still be known prints 5
}
if(true){
console.log(y); // prints 7
}
}
return innerFunction;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment