In this video we are going to learn about Module Patterns.
Lets see the different way to use module.
Go to the project and inside the calc.js file.
Create some more functions.
Lets create a function for subtract two number.

var sub = function(num1,num2){
return num1-num2;

Now create another function for multiply two numbers.

var multiply = function(num1*num2){
return num1*num2;

Now here just export these function.

module.exports.sum = sum;

Now use these methods in index.js file.
So go inside the index.js file first of all require the calc.js file.

var calc=require('./calc');

Now lets use these functions.


Now lets run this so go to the command prompt and run the command.

node index.js

Now you can see the all result on console.

You can also export module in a different way.
Goto to calc.js file.
and inside the calc.js file just export module as following.


Now lets check its working or not.
So, just re-run the index.js file and you can see its working as before.
So in this way you can use module in different way.