Node.js Notes


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


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

Continue reading “Node.js Notes”