JSFiddle - React, Tailwind, and code Playground

by chrisramakers

JavaScript

// Late prototype modifications
// 

// class is created
function Car(){}

// First instance is created
var myCar = new Car();

// Class prototype is extended
function getPk(){ 
    //document.write(this.pk, '<hr>'); 
}
Car.prototype.pk = 0;
Car.prototype.getPk = getPk;

// Second instance is created
var mySecondCar = new Car();
mySecondCar.pk = 50;

// Get PK's for both cars
myCar.getPk();
mySecondCar.getPk();