I want to copy some fields in another fields for the same object like in this demo :
var customers = {
apple: {
papa: {
en: "cool"
}
},
oranges: {
papa: {
en: "cool"
}
}
};
function deepCopyEn(src) {
if (src.hasOwnProperty("en")) {
src.fr = src.en;
src.es = src.en;
}
else {
if (src.constructor === Array) {
for (var i = 0; i < src.length; i++) {
deepCopyEn(src[i]);
}
}
else {
for (var prop in src) {
if(src.hasOwnProperty(prop)) {
deepCopyEn(src[prop]);
}
}
}
}
}
deepCopyEn(customers);
console.log(customers);
but when I tried with a class with an array and another filed the function don't work, this is an example http://pastebin.com/K7EjAnu1 it gives this error: RangeError: Maximum call stack size exceeded. Any help to update my function??