JSFiddle - React, Tailwind, and code Playground
HTML
<script>
function getOwnPropertyDescriptors(object) {
var keys = Object.getOwnPropertyNames(object),
returnObj = {};
keys.forEach(getPropertyDescriptor);
return returnObj;
function getPropertyDescriptor(key) {
var pd = Object.getOwnPropertyDescriptor(object, key);
returnObj[key] = pd;
}
}
Object.getOwnPropertyDescriptors = getOwnPropertyDescriptors;
</script>
<script>
function dup(o) {
return Object.create(
Object.getPrototypeOf(o),
Object.getOwnPropertyDescriptors(o)
);
}
</script>
JavaScript
var Animal, Cat, cat, cat2, dup;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
Animal = (function() {
function Animal() {}
Animal.sleep = function() {
return console.log('sleep');
};
Animal.prototype.wake = function() {
return console.log('wake');
};
return Animal;
})();
Cat = (function() {
__extends(Cat, Animal);
function Cat() {
Cat.__super__.constructor.apply(this, arguments);
console.log('create');
}
Cat.prototype.attack = function() {
return console.log('attack');
};
return Cat;
})();
cat = new Cat();
cat.constructor.sleep();
cat.wake();
cat.attack();
cat2 = dup(cat);
cat2.constructor.sleep();
cat2.wake();
cat2.attack();