I have a code below, every time after its get reduce its referring my same array, how to resolve this
var myobjData = data[0];
var obj = myobjData;
var arr = ['index', 'label', '__id', 'id', '__parent', '__proto__'];
var colObjLength = shorten(arr, obj);
function shorten(arr, obj) {
arr.forEach(function(key) {
delete obj[key];
});
console.log(obj);
return obj;
}
the data[0]
gets affecting because of this code. it should not affect the data[0]
value