一個node模塊,為了能夠服用,就需要將其暴露,那么如何正確寫呢?(參考:https://developer.mozilla.org/zh-CN/docs/Learn/Server-side/Express_Nodejs/Introduction)
【正確寫法A】
exports.area = width => { return width * width; }; exports.perimeter = width => { return 4 * width; };
【正確寫法B】
module.exports.area = width => { return width * width; }; module.exports.perimeter = width => { return 4 * width; };
【正確寫法C】
// 這種寫法只能用 module.exports module.exports = { area: width => { return width * width; }, perimeter: width => { return 4 * width; } };