JSFiddle - React, Tailwind, and code Playground

by mshufrich

JavaScript

function Avto(name) {
    //Private variable
    var defaultDistance = 700;
    //Public variable
    this.name = name;
    this.wheles = 4;
   
    this.engine = true;
    //Public method
    this.rashod = function(bak) {
        this.distance = bak * 12;
        console.log("Distanse:", this.distance);
    }
    //Privileged method
    this.getDefaultDistance = function(){
        return defaultDistance;
    }
}

function SmallCar(name) {
    this.name = name;
    this.children = true;
    this.seat=5;
    this.speed=110;
}

function BigCar(name) {
    this.name = name;
    this.children = false;
    this.seat=3;
    this.speed=90;
}
SmallCar.prototype = new Avto();
var Ford= new SmallCar('Fiesta');
Ford.rashod(50);
console.log("Ford", Ford.name);

BigCar.prototype = new Avto();
var MAN= new BigCar('8.180');
MAN.rashod(120);
console.log("MAN", MAN.name);