JSFiddle - React, Tailwind, and code Playground

by happyrupesh

Babel + JSX

function  newConstructor( HumanClass ) {
	// newConstructorFunc will modify or overwrite the HumanClass contructor function
	var  newConstructorFunc  =  function(firstName, lastName, age) {
		this.firstName  =  firstName
		this.lastName  =  lastName
		this.age  =  age
	}

	return  newConstructorFunc
} 

@newConstructor
class  Human {
	constructor( firstName, lastName ) {
		this.firstName  =  firstName;
		this.lastName  =  lastName;
	}
}

// Though Human class constructor function takes only two parameters, but due to 
// newConstructor now Human class can accept 3 parameters
var  person1  =  new  Human("Virat", "Kohli", 31);
console.log( person1 );

// Displays the modified constructor function
console.log( Human.prototype.constructor );
console.log(person1.__proto__.constructor);