Keyword: 15Absolutely! The bind method in JavaScript creates a new function, inheriting the context (this) from the provided object at the time of the call. This allows you to pre-configure a function's this value for future executions. Here's an example:
function sayHello(name) {
console.log("Hello, " + name + "!");
}
const person = { name: "Alice" };
const helloAlice = sayHello.bind(person); // `this` is bound to `person`
helloAlice(); // Outputs: "Hello, Alice!"
|
|
|
|