NodeJS Exporting and Importing Module
Exporting with ES6 syntax
This is the equivalent of the other example but using ES6 instead.
Using a simple module in node.js
What is a node.js module :
A module encapsulates related code into a single unit of code. When creating a module, this can be interpreted as moving all related functions into a file.
Now lets see an example. Imagine all files are in same directory:
Another way of using modules:
Run this file by going to your directory and typing: node app.js