I have created a file constant.js
var self = require("./constant");
module.exports = {
FirstName : "sourabh",
LastName : "gupta",
Name: self.FirstName + " " + self.LastName
}
here, in constant.js
I defined two properties in object FirstName, LastName and third property Name is based on the above two property which i define by requiring the same file.
I am expecting that when another file require the constant.js. let main.js
var constant = require('./constant.js');
console.log("constants>>>>>"+JSON.strinigfy(constant)); //will print {FirstName : "sourabh",LastName : "gupta",Name: "sourabh gupta"}
//but its prints - {FirstName : "sourabh",LastName : "gupta"} -- Name is undefined
As much i know this is happening due to require cache which return the constant mudule value as blank json {}.
so, i want to know that is it possible any how to get the json - {FirstName : "sourabh",LastName : "gupta",Name: "sourabh gupta"}
thanks in advance