Suppose I have the following code snippet:
const c = class {
xyz = 123;
};
With that in place, I can then execute:
new c().xyz // --> 123;
But is there a way to provide an object to automatically assign properties? In simpler terms, can I achieve something like this:
const props = { foo: 'baz!', bar: 555 };
const c = class {
...props... // convert props to properties magically -- but how?
};
And then use it as follows:
new c().foo; // --> 'baz!'
new c().bar; // --> 555
Is there a method to accomplish this?