Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JS Function.prototype.bind usage
## What does Function.prototype.bind do ?
Function.prototype.bind = function (scope) {
if (typeof this !== "function") {
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
var fn = this;
return function () {
return fn.apply(scope);

This comment has been minimized.

Copy link
Owner Author

Jerry-Lau commented Aug 25, 2017

JavaScript 中的函数原型链中有一个 bind 方法,可以用来静态绑定函数的上下文。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.