Sunday, 30 April 2017

How to get value from modified object in Node.js

how to get modified value of object? index.js is called before index2.js object.js

var object={
  size:'5 '
};

var setSize=function(size){
  object.size=size;
  }
  
  exports.object=object;
  exports.setSize=setSize;

index.js

var obj=require('path/Object);

obj.setSize('10');
console.log(obj.object.size); //--> 10

index2.js I want the result to be 10.

var obj=require('path/Object.js');
console.log(obj.object.size) //--> 5


via C A L O J Y

No comments:

Post a Comment