running the same code in different environments produces different results1
try running the code below in chrome console and on node js, the first produces snehal
snehal
and the other undefined
undefined
this.name = "snehal";
function meme() {
console.log(this.name);
function mem() {
console.log(this.name);
}
mem();
}
meme();
The basic idea about this
in JavaScript is that it points/refers to the object that contains it, so in the chrome console we can expect the inner mem function this
to be === to the meme function this, but the same is not consistent in the node environment.