. Получите JavaScript
// Call (borrow) an object's function from another object
// 'this' will bind to the borrower
// syntax: ownerObject.ownerFunction.call(borrowerObject)
const sidekick = {
name: "Robin"
}
const hero = {
name: "Batman",
saveGotham: function() {
console.log(this.name, "is keeping Gotham safe.");
}
}
hero.saveGotham(); // Batman is keeping Gotham safe.
hero.saveGotham.call(sidekick); // Robin is keeping Gotham safe.
Intra