Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 298 Bytes

File metadata and controls

16 lines (13 loc) · 298 Bytes

Section 7.2: Simple class

class Car {
  public position: number = 50;
  private speed: number = 42;

  move() {
    this.position += this.speed;
  }
}

var car = new Car(); // create an instance of Car
car.move(); // call a method
console.log(car.position); // access a public property