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);
Sur cette page du site, vous pouvez voir la vidéo en ligne JavaScript call method 📱 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Bro Code 01 septembre 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 3,010 fois et il a aimé 154 téléspectateurs. Bon visionnage!