Two returns of the bind method

The bindThis method is as follows:

 function bindThis(f, oTarget) {
    
    
            return function () {
    
    
                 return f.apply(oTarget, [...arguments])
            }
        }

The first function of return is to pass parameters to the callback function f. Through a return function, the parameters of the return function are obtained by arguments and passed to f.
The function of the second return is to return the result of the call of the callback function f. We assume that there is no second return, and there is a return in the callback function. When we execute let a=bindThis(f,oTarget)(), the result is a If it is undefined, the return value in the callback function cannot be obtained.

Guess you like

Origin blog.csdn.net/weixin_44494811/article/details/114242497