Last active
August 29, 2015 14:09
-
-
Save swapnilshrikhande/98dfcc18f05a527144d9 to your computer and use it in GitHub Desktop.
Demonstrate Closure
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 closureParentFunction(){ | |
| var localVar = 0; | |
| var localFunction = function(){ | |
| console.log('localVar=',++localVar); | |
| } | |
| setInterval(localFunction,2000); | |
| return -1; | |
| }; | |
| var variable = closureParentFunction(); | |
| console.log('returned variable',variable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment