Last active
December 10, 2015 19:59
-
-
Save aitskovi/4485474 to your computer and use it in GitHub Desktop.
varscope
This file contains 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 invalid(a) { | |
var inner = function() { | |
console.log(a); | |
var a = '2'; | |
console.log(a); | |
} | |
inner(); | |
} | |
function valid(b) { | |
var inner = function() { | |
console.log(b); | |
var a = '2'; | |
console.log(a); | |
} | |
inner(); | |
} | |
/** | |
* invalid('1') -> | |
* 'undefined' | |
* '2' | |
* | |
* valid('1') -> | |
* '1' | |
* '2' | |
* | |
* Is this expected behaviour or a bug? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment