Creating Custom Modules in Nodejs




Node.js project folder
Node.js project folder

app.js

var hello = require('./hello.js');

console.log(hello.sayHelloInEnglish());
console.log(hello.sayHelloInSpanish());

hello.js

var hello = {
sayHelloInEnglish : function() {
    return 'Hello';
},

sayHelloInSpanish : function() {
    return 'Hola';
}
};

module.exports = hello;

 

Node.js Certification Training at Simplilearn.com!


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*