Tags

Node.js Notes

Export

Here I oppose three different ways to export modules on node.js

Lets say we want to export three functions from a file called count.js

var counter = function(arr){
	return 'There are '+ arr.length + ' elements';
}

//This can be done by using backticks

var adder = function(a,b){
	return `The sum of two numbers is ${a+b}`;	
}

var pi = 3.142;

First way

//Export

module.exports.counter = counter;
module.exports.adder = adder;
module.exports.pi = pi;

Continue reading “Node.js Notes”

0