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

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.

主站蜘蛛池模板: 克山县| 汕尾市| 永平县| 衡东县| 嘉义市| 济宁市| 南郑县| 比如县| 德钦县| 康马县| 全南县| 宁国市| 策勒县| 长乐市| 咸丰县| 吉首市| 新泰市| 光山县| 双峰县| 兴安县| 苏尼特左旗| 湖南省| 奉节县| 犍为县| 尚志市| 南华县| 怀远县| 辽阳县| 宾阳县| 旺苍县| 府谷县| 巨鹿县| 金堂县| 竹山县| 华池县| 湟中县| 米林县| 井研县| 贵州省| 扶绥县| 临邑县|