Skip to content

Instantly share code, notes, and snippets.

@cagataycali
Created November 22, 2021 12:21
Show Gist options
  • Save cagataycali/1d67b90706f8ed8a517d153a2592d12a to your computer and use it in GitHub Desktop.
Save cagataycali/1d67b90706f8ed8a517d153a2592d12a to your computer and use it in GitHub Desktop.
[JavaScript] Naive bind
// 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