-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
deepClony doen't works with non enumerable properties, such below e.g.:
class e {
id;
data;
constructor(data) {
this.id = Math.floor(Math.random() * 25);
this.data = data;
Object.defineProperty(this, "gTr", {
enumerable: false,
value: function () {
return "it's me! " + this.id;
}
});
}
}
const i = new e({ a: 1, b: 2 });
const u = Object.assign(
Object.create(i),
Object.getPrototypeOf(Object.create(i))
);
const o = deepCopy(i);
u.id = 28;
u.data.a = 3;
o.data.a = 4;
console.log(
"i:",
i.gTr && i.gTr(),
i.data.a,
"o:",
o.gTr && o.gTr(),
o.data.a,
"u:",
u.gTr && u.gTr(),
u.data.a
);output:
i:
it's me! 23
3
o:
undefined
4
u:
it's me! 28
3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels