Skip to content

Instantly share code, notes, and snippets.

@topicus
Created December 14, 2014 01:22
Show Gist options
  • Select an option

  • Save topicus/8c91821bdc8c2ad2e5db to your computer and use it in GitHub Desktop.

Select an option

Save topicus/8c91821bdc8c2ad2e5db to your computer and use it in GitHub Desktop.
function hola(){
var myvar = 'hola';
console.log('1.' + myvar); //prints '1. hola'
function mundo(){
console.log('2.' + myvar); //prints '2. hola'
}
mundo();
}
hola()
// throws an error: Uncaught ReferenceError: myvar is not defined
// because myvar it's only available within hola function
console.log('3.' + myvar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment