pablocattaneo
11/9/2017 - 12:00 PM

Convert Typescript object into a plain object.

Convert Typescript object into a plain object #typescript #object #plainObject

class Point {
    private x: number;
    private y: number;

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }

    getX(): number {
        return this.x;
    }

    getY(): number {
        return this.y;
    }
}

let p1 = new Point(4, 5);
let p2 = Object.assign({}, p1);