Answers for "typescript class constructor overload"

1

typescript class constructor overload

class Box {
    public x: number;
    public y: number;
    public height: number;
    public width: number;

    constructor();
    constructor(obj: IBox); 
    constructor(obj?: IBox) {    
        this.x = obj?.x ?? 0
        this.y = obj?.y ?? 0
        this.height = obj?.height ?? 0
        this.width = obj?.width ?? 0;
    }   
}
Posted by: Guest on March-03-2022

Code answers related to "typescript class constructor overload"

Code answers related to "Javascript"

Browse Popular Code Answers by Language