JSFiddle - React, Tailwind, and code Playground
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();
dup = function(obj) {
// what goes here so dup(cat) doesn't log 'create'
};
cat2 = dup(cat);
cat2.constructor.sleep();
cat2.wake();
cat2.attack();