官术网_书友最值得收藏!

Exporting files from note.js to use in app.js

For now though, the focus will be to export something from notes.js which we can use in app.js. Inside notes.js (actually, inside all of our Node files), we have access to a variable called module. I'll use console.log to print module to the screen so that we can explore it over in Terminal, as shown here:

console.log('Starting notes.js');

console.log(module);

Let's rerun the file to explore it. As shown in the following screenshot, we get a pretty big object, that is, different properties related to the notes.js file:

Now, to tell the truth, we'll not be using most of these properties. We have things such as id, exports, parent, and filename. The only one property we'll ever use in this book is exports.

The exports object on the module property and everything on this object gets exported. This object gets set as the const variable, notes. This means that we can set properties on it, they will get set on notes, and we can use them inside app.js.

主站蜘蛛池模板: 林甸县| 抚顺市| 桑植县| 上饶县| 越西县| 韶山市| 镇巴县| 革吉县| 平果县| 泾阳县| 布拖县| 阆中市| 布尔津县| 宽甸| 龙陵县| 禹城市| 朝阳区| 西昌市| 盈江县| 玉山县| 亚东县| 普兰店市| 上林县| 潍坊市| 丽水市| 南阳市| 南充市| 洪江市| 义马市| 桓台县| 建始县| 桐乡市| 广汉市| 台东市| 若尔盖县| 红桥区| 大同县| 洪泽县| 南华县| 包头市| 高州市|