Skip to content

call()

call() invokes the function with a given this value and arguments provided individually.

function greet(city, country) {
console.log(`${this.name} lives in ${city}, ${country}`);
}
const person = { name: "Alice" };
greet.call(person, "Paris", "France"); // Alice lives in Paris, France