Skip to content

Instantly share code, notes, and snippets.

@rebolyte
Last active September 3, 2021 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebolyte/f38725e9633d64d4376748fee0f53c48 to your computer and use it in GitHub Desktop.
Save rebolyte/f38725e9633d64d4376748fee0f53c48 to your computer and use it in GitHub Desktop.
Function.prototype.myBind = function myBind(ctx, ...baseArgs) {
const that = this;
return function (...args) {
that.call(ctx, ...baseArgs, ...args);
}
}
function tester(...args) {
console.log(this.aProp, ...args);
}
const ctx = {
aProp: 123
}
const doIt = tester.myBind(ctx, 'SYNC');
doIt('abc');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment