I want to be able to create a series of objects in JSON like this:
const objects = {
type1: {
inputs: [value1, resultOfFunction(), value3],
typeFunction: (arg1, arg2, arg3) => {
//this does a thing with the inputs and returns an output
}
},
type2: {
inputs: [val1, val2],
typeFunction: (arg1, arg2) => {
//this does a thing with these inputs and returns an output
}
}
}
The point here is that each type
contains some kind of blackbox function that takes a series of arguments and returns a value. The number of arguments will differ with each type, as will the values of those arguments. I have suggested there is an array inputs
that specifies what values are to be passed into each function, but I am open to alternatives.
How can I then generically call these functions with their respective inputs? e.g.
type1.typeFunction() //obvs this doesn't work