Skip to content

Instantly share code, notes, and snippets.

@skanev
Created October 31, 2012 21:53
Show Gist options
  • Select an option

  • Save skanev/3990174 to your computer and use it in GitHub Desktop.

Select an option

Save skanev/3990174 to your computer and use it in GitHub Desktop.
Scoping and shadowing in JavaScript
var x = 1;
(function() {
var x = x + 1; // prints NaN
console.log(x);
})();
(function (x) {
console.log(x); // prints 2
})(x + 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment