I would like to cache data from remote database locally to use it in my javascript application. I do not need any excesses such as SQL requests to local data, so I decide just to store database records in array of objects in the following way:
<script type="text/javascript">
var json0 = '{"1" : {"fname": "fname1", "sname": "sname1"}, "2" : {"fname": "fname2", "sname": "sname2"}}';
var json1 = '{"2" : {"data": "11/05/2014", "time": "11:30:18", "person": "data0[1]"}, "6" : {"data": "24/06/2014", "time": "16:11:05", "person": "data0[2]"}, "8" : {"data": "11/10/2014", "time": "12:15:27", "person": "data0[1]"}}';
var data0 = JSON.parse(json0);
var data1 = JSON.parse(json1, function (k, v) {
try {
return eval(v);
} catch (e) {
return v;
}
});
console.log(data1);
</script>
The question is about the memory usage. If the objects in array data1 will store the reference to the objects from data0 in the property "person" or they will store the copy of these objects?