Skip to content

Instantly share code, notes, and snippets.

@ykarikos
Created May 5, 2017 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ykarikos/94b4fdb3136f205d40e0f7f8a16bdf2a to your computer and use it in GitHub Desktop.
Save ykarikos/94b4fdb3136f205d40e0f7f8a16bdf2a to your computer and use it in GitHub Desktop.
What does each logging statement print, why?
// What does each logging statement print, why?
var x = 1;
console.log(x);
if(1) {
var x = 2;
console.log(x);
}
console.log(x);
var x = 10;
function foo(x) {
if(!x) {
x = 4;
}
console.log(x, arguments);
};
foo.call(7);
var foo = (function() {
console.log(x);
})();
foo(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment