I have a custom object with multiple attributes stored in an array.
class Test {
a1;
a2;
a3;
a4;
a5;
}
In my project, I have an array that always follows the same order as the attributes of the Test object.
arrayWithValues = [a1,a2,a3,a4,a5];
To simplify the creation process, I am looking to add a static method to the Test class that can generate new instances based on an array of values.
createNewTestObject (param: []) {
... Including a constructor if necessary.
}
I aim to iterate through each attribute defined in the class and instantiate a new object using the provided array values.
Is this feasible?