Is there a neater way to assign the values to objects rather than what I have:
My code:
let val1 = result.data.data.table.val1;
let val2 = result.data.data.table.test.val2;
let val3 = result.data.data.table.val3;
let val4 = result.data.data.table.val4;
let val5 = result.data.data.table.val5;
Is there a neater way to assign this, a one-liner?
2
Answers
I think what you’re looking for is destructuring.
NOTE: Please use the destructing code above to solve your problem, but the code below is an alternative if the the value that you are assigning changes.
PS: the for loop is just an example you can pretty much use anything just be aware of what you are assigning and what the value should be, this isn’t the best solution but it is a solution.