Hi Beginner here so sorry for any ignorance if I showed.
const test = {
myfunction(){
console.log(this);
},
myfunction3(){
function myfunction4(){
console.log(this)
}
return myfunction4()
} }
and when I run
test.myfunction3()
I receive global object as a window. I am a little bit confused how this happened. My question is
myfunction3()
can access tomyfunction4()
because of its hierarchy? If so, is there anyway I can access tomyfunction4()
directly instead of going through myfunction3()?- Why
this
inmyfunction4()
returned global window instead of a reference tomyfunction4()
?
Thank you for your help!