Understand the Function. prototype. bind method in javascript, prototype. bind
When we are new to Javascript, we may not need to worry about function binding, but when we need to keep the context object this in another function, we will encounter corresponding problems, I have seen many people assign this value to a variable (such as self, _ this, And that), especially var that = this is the most common problem I have seen, in this way, you can use it after changing the environment. These are all possible, but there is also a better and more proprietary method, that is, using Function. prototype. bind, which will be explained in detail below.
Part 1: Problems to be Solved
Var myObj = {specialFunction: function () {}, anotherSpecialFunction: function () {}, getAsyncData: function (cb) {cb () ;}, render: function () {this. getAsyncData (function () {this. specialFunction (); this. anotherSpecialFunction () ;}}}; myObj. render ();
For more information, see