JSFiddle - React, Tailwind, and code Playground
JavaScript
function getObject(cls, args){
function _cls(){};
_cls.prototype = cls.prototype;
var obj = new _cls();
cls.apply(obj, args);
return obj;
}
function employee(name, age){
this.name = name;
this.age = age;
}
employee.prototype.show = function(){
alert(this.name + ': ' + emp.age);
}
var emp = getObject(employee, ['Jack', 26]);
emp.show();