- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript call, apply and bind
JavaScript Functions
JavaScript call, apply and bind
JavaScript
call,applyandbindlet you choose what thethiskeyword refers to inside a function.
Normally this depends on how a function is called.
These three methods let you set it yourself.
Example
Example
javascript
const person = { name: "Ada" };
function greet() {
return "Hello " + this.name;
}
console.log(greet.call(person));