Inheritance Snippet

    0

    45

    Jose Romero

    ES6
    JavaScript recipes

    Example of class inheritance through a Shape example

    class Shape {
      constructor(x, y) {}
    }
    
    class Movable extends Shape {
      constructor(x, y) {
        super(x, y);
      }
    
      move(dx, dy) {
        this.x += dx;
        this.y += dy;
      }
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.