What object does this reference in module scope (i'm referring to node.js modules)?
console.log(this);
console.log(this === module); //false
It isn't referencing to module object so where is it pointing to?
What object does this reference in module scope (i'm referring to node.js modules)?
console.log(this);
console.log(this === module); //false
It isn't referencing to module object so where is it pointing to?
Strangely, it's equal to module.exports
console.log(this === module.exports); // => true
Personally, I think this is dumb. But it is what it is.
I have no idea why we have 3 references to the same exact thing. this, exports, and module.exports all reference the same object.
My best guess is it's some backwards compatibility. I could easily be wrong about that tho.