Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fud/cd432afe11549e051c7db9d8b184391f to your computer and use it in GitHub Desktop.
Save fud/cd432afe11549e051c7db9d8b184391f to your computer and use it in GitHub Desktop.
prototypical method binding Proxy
function bindContext(object){
return new Proxy({
get: function(target, key){
if(typeof target[key] === 'function' && !target.hasOwnProperty(key)){
return target[key].bind(target);
}
return target[key];
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment