Hello,
I have some questions about the II lesson of Javascript Modules.
At the section module.exports the defined function celsiusToFahrenheit()
used in the code snippet is assigned to module.exports.celsiusToFahrenheit
to demonstrates the first way of exporting functions from a module.
1- Why it is:
module.exports.celsiusToFahrenheit = celsiusToFahrenheit;
instead of:
module.exports.celsiusToFahrenheit = celsiusToFahrenheit();
I understand that the way this works is to assign a new property to module.exports called celsiusToFahrenheit, I would expect that its value would be celsiusToFahrenheit(), but it seems it is called like a getter function would be called, without the parentheses, anyone can help me understand why’s that?.
2- Also, English not my native language, I don’t understand the sentence “exporting functions from a module”. Shouldn’t be “exporting to a module”, while for import “importing from a module”?