Created
September 20, 2013 12:08
-
-
Save ekho/6636509 to your computer and use it in GitHub Desktop.
javascript callback with specified context
This file contains 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 hitch(func, context){ | |
return function(){ | |
return func.apply(context, arguments); | |
}; | |
}; | |
// example will out to browser console object myOwnContext after clicking on specified element | |
$('...').click( | |
var myOwnContext = {prop: 1}; | |
hitch(function(){ console.dir(this); }, myOwnContext); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment