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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |
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 testClosure (){ | |
var x = 4; // local variable | |
return x; | |
} | |
testClosure(); // this will return 4 | |
x; // will return undefined because a function variable are not available once the scope has closed |
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 testClosure (){ | |
var x = 4; | |
function closeX(){ | |
return x; // NB: x is not stored anywhere in the innermost function its a global variable | |
} | |
return closeX; | |
} | |
var checkLocalX = testClosure(); |