Created
December 14, 2014 01:22
-
-
Save topicus/8c91821bdc8c2ad2e5db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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