In my app i have two modules, which both need one object variable, but in them, they alter its content slightly:
In app.js
var example = {title: "test"};
var admin = require('./admin');
var research = require('./research');
admin.data(example);
research.data(example);
console.log(admin.get());
console.log(research.get());
In research.js
var datasnapshot = null;
module.exports = {data: updateData, get: getData};
function updateData(data) {
datasnapshot = data;
}
function getData() {
return datasnapshot
}
In admin.js
var datasnapshot = null;
module.exports = {data: updateData, get: getData};
function updateData(data) {
datasnapshot = data;
datasnapshot.title = "Admin Panel";
}
function getData() {
return datasnapshot
}
The problem is, that botch console.log() return me {title: "Admin Panel"}, despite the fact, that i only want it to be like so in second module. Thank you in advance for assistance!