I am starting a series on node js. Actually I’m not super skilled with node js. So I thought let’s start from zero again and help others with me to learn about it. I saw the ‘the net ninja’ tutorials and took the syllabus from there and make a fusion of my own. I want to help you with my journey, let’s ride together into node js for 30 days…
Day 7 — Learning Node JS In 30 Days [Mini series]
A full series to learn the basics easily of node js
Today we’re going to learn about some more about module
We are using files as last posts. Now it can happens that in our song
folder there are two different functions.
Now how to send this both module, as per we know from last posts we can’t send both functions using this module.exports
Adding module.exports.VARIABLE_NAME
we can send it to other file
By using Song.VARIABLE_NAME
what we’ve send from song.js
file we can call the functions
This is not all, there are some others way you can do it to. What if you have 100 functions in the same file are you going to write one by one ?
Now we can just use module.exports as a object ! Example –
app.js
will be the same and if we run it now then same result
now we can modify code a bit. When the name are same in es6 version we can write just once.
So, do you feel you know a bit about module now ?
Originally it published on nerdjfpb blog and graphical version on instagram. you can connect with me in twitter, linkedin or instagram