In this query, i've have small doubt i need to know WHY?
We are in #lockdown mean while one of my brother padu asked this question. Below i have sample object, in that there have functions while calling as directly its return 1 but while assign as const and access as function returns undefined. Someone have any explainations will real helpful to imporve my knowledge.
const apple = 3;
const data = {
apple: 2,
bag: {
apple: 1,
plastic: function(){
return this.apple;
}
}
}
const plastic = data.bag.plastic;
console.log(plastic()) **//Result - undefined**
console.log(data.bag.plastic()) **//Result - 1**
Thanks,
Gopal.R