const person = { name: 'Lydia' }; function sayHi(age) { return `${this.name} is ${age}`; } console.log(sayHi.call(person, 21)); console.log(sayHi.bind(person, 21));
undefined is 21
Lydia is 21
function
With both, we can pass the object to which we want the this keyword to refer to. However, .call is also executed immediately!
this
.call
.bind. returns a copy of the function, but with a bound context! It is not executed immediately.
.bind.