Skip to content

Instantly share code, notes, and snippets.

@ekho
Created September 20, 2013 12:08
Show Gist options
  • Save ekho/6636509 to your computer and use it in GitHub Desktop.
Save ekho/6636509 to your computer and use it in GitHub Desktop.
javascript callback with specified context
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