tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code04:27

What is THIS in JavaScript? 👈

Bro Code ↗

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.

Keep exploring Learn to Code