Skip to content

Instantly share code, notes, and snippets.

@toreholmberg
Last active December 11, 2015 21:08
Show Gist options
  • Select an option

  • Save toreholmberg/4660000 to your computer and use it in GitHub Desktop.

Select an option

Save toreholmberg/4660000 to your computer and use it in GitHub Desktop.
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
// usage
$('selector').click(__bind(this.handler, this));
// or
this.handler = __bind(this.handler, this);
$('selector').click(this.handler, this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment