February 2018
Intermediate to advanced
298 pages
8h 22m
English
Previously, we said that you can use exports.math or module.exports.math in order to export a variable from the module. What's the difference between two?
Well, technically, exports and module.exports point to the same object. You can think about this in the following manner:
exports = module.exports = { }
This is how it starts. Now it doesn't matter whether you assign a property value to module.exports or exports because they both point to the same object. However, you must remember that it is module.exports that is actually exported!
For example, consider string1.js, string2.js, and index.js.
string1.js is shown as follows:
// string1.jsmodule.exports = () => "Amazing string" // correct export of function
Read now
Unlock full access