Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save swapnilshrikhande/98dfcc18f05a527144d9 to your computer and use it in GitHub Desktop.

Select an option

Save swapnilshrikhande/98dfcc18f05a527144d9 to your computer and use it in GitHub Desktop.
Demonstrate Closure
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