JSFiddle - React, Tailwind, and code Playground
JavaScript
var shape = defclass(null, function () {
this.constructor = function () {
this.x = 0;
this.y = 0;
};
this.move = function (x, y) {
this.x += x;
this.y += y;
alert("Shape moved.");
};
});
var rectangle = defclass(shape, function (shape) {
this.constructor = function () {
shape.constructor.call(this);
};
});
var rect = rectangle.new();
rect.move(2, 1);
function defclass(type, body) {
var neo = function () {
var self = new constructor;
return prototype.hasOwnProperty("constructor") &&
prototype.constructor.apply(self, arguments), self;
};
var constructor = function () {}; constructor.prototype = type;
var prototype = constructor.prototype = new constructor; prototype.new = neo;
return body.call(prototype, type), prototype;
}