07:31What is THIS in JavaScript? 👈
From the creator
#JavaScript #tutorial #course // this = reference to the object where THIS is used // (the object depends on the immediate context) const person1 = { name: "Spongebob", favFood: "hamburgers", sayHello: function(){console.log(`Hi! I am ${this.favFood}`)}, eat: function(){console.log(`${this.name} is eating ${this.favFood}`)} } const person2 = { name: "Patrick", favFood: "pizza", sayHello: function(){console.log(`Hi! I am ${this.favFood}`)}, eat: function(){console.log(`${this.name} is eating ${this.favFood}`)} } person1.eat(); person2.eat();
Published 2023-11-15 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.





