...

/

Solution Review: Bind Function

Solution Review: Bind Function

This lesson will explain the solution to the problem in the previous lesson.

Solution #

Press + to interact
const bind = (fn, obj) => (...args) => fn.apply(obj, args)
function multiply(a) {
console.log(this.val * a.val2);
}
var obj = {val : 2}
function callingBind(){
const bindFunc = bind(multiply, obj)
bindFunc.call(this,{val2 : 2})
}
callingBind()
...
Access this course and 1400+ top-rated courses and projects.