Wednesday, 17 April 2019

bind and apply

https://medium.com/@ivansifrim/the-differences-between-call-apply-bind-276724bb825b

javascript bind example

let obj = {things: 3};
let addThings = function(a, b, c){
return this.things + a + b + c;
};
let fn=addThings.bind(obj); //bind will return the function copy and obj parameter which took place of this.
fn(1,2,3);
//console.log( addThings.bind(obj)(1,4,6) );

No comments:

Post a Comment