Skip to content

Instantly share code, notes, and snippets.

@psahni
Created May 9, 2014 13:23
Show Gist options
  • Save psahni/81fd42e88d02dab679fa to your computer and use it in GitHub Desktop.
Save psahni/81fd42e88d02dab679fa to your computer and use it in GitHub Desktop.
clousures in javascript
function add(x,z) {
value = function(y) {
return x + y;
};
if(typeof(z)=='undefined'){
return value;
}else{ return (x+z);}
}
alert(add(5,6));
alert(add(5)(6));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment