Created
November 22, 2021 12:21
-
-
Save cagataycali/1d67b90706f8ed8a517d153a2592d12a to your computer and use it in GitHub Desktop.
[JavaScript] Naive bind
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
// Bind returns function closure for later usage, | |
Function.prototype.myBind = function (context) { | |
const fn = this; | |
return function () { | |
fn.apply(context, arguments); | |
} | |
} | |
// Apply, bind invokes the function immediately. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment