Last active
November 3, 2017 01:30
-
-
Save KoryNunn/5c6cb954a6d9be930d2a9b873cc34797 to your computer and use it in GitHub Desktop.
prototypical method binding Proxy
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 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