Binding this to a function by bind is called hard binding, and the problem with hard binding is that it can no longer change this pointing anyway (you can’t change this pointing by explicit binding or implicit binding).

Soft binding is designed to solve this problem. Here is a simple soft binding example

Function. The prototype. SoftBind = Function (obj) {/ / there is no currie of the bind Function, can add var fn = this; return function () { return fn.apply((! this || this == window) ? obj : this, arguments) } } var a=function(){console.log(this)} var b=a.softBind(1) b(); b.call(2)Copy the code