Skip to content

Instantly share code, notes, and snippets.

@laustdeleuran
Created February 6, 2012 16:38
Show Gist options
  • Save laustdeleuran/1753169 to your computer and use it in GitHub Desktop.
Save laustdeleuran/1753169 to your computer and use it in GitHub Desktop.
Scoped variables example
var globalScope = "I'm in the global scope";
var scopedFunction = function(){
var localScope = "I'm not in the global scope";
console.log(localScope);
};
console.log(globalScope);
// Outputs "I'm in the global scope"
scopedFunction();
// Outputs "I'm not in the global scope";
console.log(localScope);
// Fails - is 'undefined'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment