Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidlygagnon/c4e6c0a127bbcd7ead9ec55f957f4da8 to your computer and use it in GitHub Desktop.

Select an option

Save davidlygagnon/c4e6c0a127bbcd7ead9ec55f957f4da8 to your computer and use it in GitHub Desktop.

Revisions

  1. davidlygagnon created this gist Apr 20, 2019.
    20 changes: 20 additions & 0 deletions example-constructor-instantiation-js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // JavaScript
    class SportCar extends Car {
    constructor(model, wheelsProperties) => {
    super();
    this.model = model;
    this.wheelsProperties = wheelsProperties;
    }
    }

    class Car {
    constructor() => {
    computeWheelMaintenance();
    }

    computeWheelMaintenance() => {
    if (this.wheelsProperties.shouldDoMaintenance) {
    // do maintenance
    }
    }
    }