this === old object
aleksanderaleksic opened this issue · 2 comments
aleksanderaleksic commented
I am using "this" within a method of a deep cloned object .
But for some reason "this" is the same object as the old object after cloning.
example:
const user = new User();
const clone = Cloner.deep.copy(user);
clone.id = '333';
// Invoke method on clone
clone.getThis() === user // returns true
clone.getThis() === clone // returns false
So after setting a new property value on the clone and invoking a method on the clone,
this.id is equal to the old value.
WebReflection commented
What is user? Is the method bound? Is the method an arrow function?
aleksanderaleksic commented
It was just me using arrow functions wrong.