Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car {
- public model: string;
- public price: number;
- public autopilot: boolean;
- constructor(model: string, price: number, autopilot: boolean) {
- this.model = model;
- this.price = price;
- this.autopilot = autopilot;
- }
- produce() {
- return new Car(this.model, this.price, this.autopilot);
- }
- }
- const prototypeCar = new Car('Sport', 100500, false);
- const car1 = prototypeCar.produce();
- const car2 = prototypeCar.produce();
- const car3 = prototypeCar.produce();
- console.log(car1);
- car1.price = 123456;
- console.log(car1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement