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

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.

主站蜘蛛池模板: 九寨沟县| 安溪县| 宁城县| 呼图壁县| 中江县| 民权县| 蓝山县| 永泰县| 六安市| 绩溪县| 江门市| 临高县| 韶山市| 黎平县| 沈丘县| 田林县| 古丈县| 鄂伦春自治旗| 黄石市| 将乐县| 嘉峪关市| 常山县| 凤城市| 安徽省| 伊春市| 白朗县| 吴旗县| 昆明市| 丰原市| 迁西县| 莎车县| 新沂市| 闻喜县| 中方县| 汉中市| 昌宁县| 高陵县| 阿城市| 桃江县| 河间市| 玉溪市|