JavaScript call method 📱

Published: 01 September 2021
on channel: Bro Code
3,010
154

Javascript call() method tutorial example explained

#JavaScript #call #method

// ******** index.js ********

// call() = predefined method that can
// call a method belonging to
// another object.

// Whichever object you want to use
// that method with, pass that object
// as an argument within call()
// this = object passed in

let employee = {
name: "Spongebob",
cook: function (){
console.log(this.name,"is cooking");
}
}
let supervisor = {
name: "Squidward",
cashier: function (){
console.log(this.name,"is at the cash register");
}
}
let boss = {
name: "Mr.Krabs",
beInCharge: function (){
console.log(this.name,"is in charge");
}
}

//employee.cook();
//supervisor.cashier();
//boss.beInCharge();

employee.cook.call(supervisor);
supervisor.cashier.call(boss);
boss.beInCharge.call(employee);


On this page of the site you can watch the video online JavaScript call method 📱 with a duration of hours minute second in good quality, which was uploaded by the user Bro Code 01 September 2021, share the link with friends and acquaintances, this video has already been watched 3,010 times on youtube and it was liked by 154 viewers. Enjoy your viewing!