I'd like to have one master class with the methods derived from many other functions attached to it. So say I have
class MasterObject {
method1...,
method2...,
etc...
}
Using ES6, id like to import these functions to assign to the MasterClass as methods. So I have tried something like this:
function setUpObj (...fns) {
class MasterObj {
constructor (...args) {
Object.assign(this, args)
}
}
return new MasterObj(fns)
}
let master = setUpObj(square, add, divide)
master.square(1,2)
When I do this, the methods are not actually assigned to the object (I am assuming they are assigned to the this, but not as methods). Clearly I don't understand how prototypical inheritance works, so if you can explain it in terms of ES6 classes that would really help me a lot.
Relevant: https://gist.github.com/allenwb/53927e46b31564168a1d ES6 Class Multiple inheritance