Wednesday 9 February 2022

Nodejs- module exports

module exports

->it will help to get/fetch one module data into another module

main.js 

var name = "Kamal"
var person = function(a,b){
    var c = a+b
    console.log("sum of "+ a +" and "+ b +" is "+ c)
}

person(5,5);

module.exports.exp_example = name;


global_object.js

var main = require("./main")
console.log(__dirname)
console.log(__filename)
console.log(main.exp_example)


OUTPUT-

K:\NodeJs\Node Basics\chapter-1

K:\NodeJs\Node Basics\chapter-1\globalObject.js

Kamal

No comments:

Post a Comment

Kotlin - Observer

 Rxjava -  Observer - Based on data view willl render (react) karega. trotling -> making stream for execution (Means clicks event fire kr...