JSFiddle - React, Tailwind, and code Playground
JavaScript
var object = function (o) {
function F() {};
F.prototype = o;
return new F();
};
/**
* Parent class
*/
var Phone = {
name: 'Phone',
init: function (variable) {
console.log('constructor');
this.name = variable;
},
getName: function () {
return this.name;
}
};
/**
* Child class
*/
var Nokia = Object.create(Phone, {
name: {
value: 'Nokia 6599'
}
});
console.log(Nokia.getName());
var Nokia2 = object(Phone);
console.log(Nokia2.getName());