+ 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
4 Respostas
+ 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)
+ 1
visph helloo there. I don't know whether you're active on sololearn. Could you help me please?
+ 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
+ 1
visph thanks very much for taking the time to respond to me. I appreciate you ☺️