Is there a way to push an object into two different arrays without sharing the reference?
Below is the object in question:
minigroup = {
"Id": response[0].Id,
"MemberId": response[0].MemberId,
"NotMemberId": response[0].NotMemberId
}
I've tried this code snippet for testing purposes:
groupCache.push(minigroup);
groupCache[0].MemberId = [0, 0, 0, 0, 0];
groupCacheOriginal.push(minigroup);
console.log("cache: " + groupCache[0].MemberId);
console.log("original: " + groupCacheOriginal[0].MemberId);
The logged results are as follows:
cache: 0,0,0,0,0
original: 0,0,0,0,0
Any suggestions on how to avoid this issue?