JSFiddle - React, Tailwind, and code Playground

by chrisramakers

JavaScript

// Definition with not-shared properties and objects
function Car(color, doors, pk){
    this.color = color;
    this.doors = doors;
    this.pk    = pk;
    this.drivers = new Array('Jan', 'Chris');
}

// Modify the prototype with the shared function
Car.prototype.getColor = function(){
    return this.color;
}
    
var myCar = new Car('black', 3, 90);
var mySecondCar = new Car('red', 3, 350);

// Benny wil ook eens met de ferrari rijden
mySecondCar.drivers.push('Benny'); 

//document.write(mySecondCar.drivers, '<hr>');
//document.write(myCar.drivers);