sdfxs

Untitled

May 11th, 2021
626
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Car {
  2.     public model: string;
  3.     public price: number;
  4.     public autopilot: boolean;
  5.  
  6.     constructor(model: string, price: number, autopilot: boolean) {
  7.         this.model = model;
  8.         this.price = price;
  9.         this.autopilot = autopilot;
  10.     }
  11.  
  12.     produce() {
  13.         return new Car(this.model, this.price, this.autopilot);
  14.     }
  15. }
  16.  
  17. const prototypeCar = new Car('Sport', 100500, false);
  18.  
  19. const car1 = prototypeCar.produce();
  20. const car2 = prototypeCar.produce();
  21. const car3 = prototypeCar.produce();
  22.  
  23. console.log(car1);
  24. car1.price = 123456;
  25. console.log(car1);
RAW Paste Data