const person = {
name: "aman",
age: 19,
hello: [2,123,13,1,23],
showDetails(){
this.hello.forEach(function(items){
console.log(this) // referring to window object
})
}
}
person.showDetails()
and other is
const person = {
name: "aman",
age: 19,
hello: [2,123,13,1,23],
showDetails(){
this.hello.forEach((items)=>{
console.log(this) // referring to person object
})
}
}
person.showDetails()
here in both cases the program is logging different output.