Inheritance Snippet

    0

    64

    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
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.