+ 2

Why true?

I understand every file in node is a module and the code is encapsulated inside an IFFE under the hood so I don't expect "this" to be global but why is it equal to the alias for module.exports? I'm thinking "this" is yet another reference to module.exports because exports is an object and two objects in js can never be equal unless one references the other. https://code.sololearn.com/cfRY37ZNRSmc/?ref=app

4th Dec 2021, 2:57 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
4 Respuestas
+ 1
I think this article about module.exports / exports could give you some (indirect) explanation: https://www.freecodecamp.org/news/node-js-module-exports-vs-exports-ec7e254d63ac/ As I understand, 'this' target 'exports' as that's the object used to communicate from / to outside the current module... (think as a module as a form of class / constructor function, where 'this' is initialized with a blank instance)
5th Dec 2021, 1:45 AM
visph
visph - avatar
+ 1
visph helloo there. I don't know whether you're active on sololearn. Could you help me please?
4th Dec 2021, 2:58 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 1
visph look at this result. The "this" in the regular function referenced to the global but for arrow func, it referenced to exports. I think the wrapper function which wraps every module in node file has some arguments that's causing this. I wish I could read that anonymous wrapper to see its args.https://code.sololearn.com/cfRY37ZNRSmc/?ref=app https://code.sololearn.com/cfRY37ZNRSmc/?ref=app
5th Dec 2021, 3:34 AM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 1
visph thanks very much for taking the time to respond to me. I appreciate you ☺️
5th Dec 2021, 7:25 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar