I have the following code (building my own little object-based-api...)
operator = {};
operator.set_data = function (json) {
this.data = json
};
operator.first_load_chart = function () {
let ref_data = operator.data;
ref_data['date'] = ref_data['date'].map(x => x ? new Date(x * 1000) : null);
};
The operator.first_load_chart
is run after operator.data
is first assigned and operator.data['date']
is first unix timestamps.
Yet when I run console.log(operator.data['date'])
in console after operator.first_load_chart
operator.data['date]
has now changed to a Date
object?
Why is this, and how can I prevent this mutation?