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.move = function(n) {
        this.distance = n;
        console.log(this.distance);
    }
    //Privileged method
    this.getDefaultDistance = function(){
        return defaultDistance;
    }
}
//Public method
Avto.prototype.getName = function() {
    return name;
}; 

function Small(name) {
    this.name = name;
}

Small.prototype = new Avto();

big = new Small('Chuk');
small = new Small('Gek');

console.log(big.name)  // Chuk
console.log(small.name) // Gek

console.log(big.canWalk) // true

big.move(2);
big.getDefaultDistance();