Why _.clone() doesn't copy object methods?

34 Views Asked by At

I use the underscore library to copy objects, the _.clone() method. And this method works differently on different versions of angular, or maybe the problem is something else?

F.e:

class FooBar {
    foo: string;
    bar: number;
    
    constructor(foo: string, bar: number) {
        this.foo = foo;
        this.bar = bar;
    }
    
    toString() {
        return this.foo;
    }
}
...
const foo = new FooBar("fooBar", null);
const bar = _.clone(foo);
console.log(bar); // Angular v12 output: {foo: "fooBar", bar: ƒ}, Angular v13 output: {foo: "fooBar"}

Why wasn't the method copied?

Dependencies before/after "ng update"

0

There are 0 best solutions below