Last active
September 3, 2021 21:07
-
-
Save rebolyte/f38725e9633d64d4376748fee0f53c48 to your computer and use it in GitHub Desktop.
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.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