JSFiddle - React, Tailwind, and code Playground

JavaScript

function addMethod(object, name, fn) {
	object[name] = fn;
}

function Parent() { this.x = 1; };
Parent.prototype.test = function (a) { return [this.x, a]; };

function Child() { Parent.call(this); this.x = 2; };
Child.prototype = Object.create(Parent.prototype);


addMethod(Child.prototype, 'test', function (a) {
  var array = super(20);
  array.push(a);
  return array;
});

var ch = new Child;
console.log(ch.test(30)); // [ 2, 20, 30]