Created
March 30, 2013 07:20
-
-
Save jeffreyiacono/5275725 to your computer and use it in GitHub Desktop.
currying (http://jsfiddle.net/jeffreyiacono/5GaN2/1/)
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
<html> | |
<head> | |
<script type="text/javascript" src="curry.js" /> | |
<title>currying in javascript</title> | |
</head> | |
<body> | |
<div id="item">default</div> | |
</body> | |
</html> |
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() { | |
function request(some_param, callback) { | |
resp = { | |
responseText: some_param + " :: something from request" | |
}; | |
callback(resp); | |
} | |
function update(id) { | |
return function(resp) { | |
document.getElementById(id).innerHTML = resp.responseText; | |
}; | |
} | |
request("some param", update("item")); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment