const user = {
name: "Praveen",
videos: ["html", "css", "js"],
greet() {
console.log(`welcome ${this.name}`);
const getVideos = () => {
console.log(`You have ${this.videos.length} videos`);
};
getVideos();
},
};
user.greet();
I am able to access the value of the videos.length
in the above code (I have used arrow function), but I am not able to access the value of the videos.length
in the below code:
const user = {
name: "Praveen",
videos: ["html", "css", "js"],
greet() {
console.log(`welcome ${this.name}`);
const getVideos = function () {
console.log(`You have ${this.videos.length} videos`);
};
getVideos();
},
};
user.greet();