Hello everyone. Let’s say for instance, I have a colors object containing several array of colors like this:
const colors = { primaryColors: [‘Red’, ‘Yellow’, ‘Blue’ ], secondaryColors: [‘Green’, ‘Purple’, ‘Orange’], tertiaryColors: [‘Green’, ‘Purple’, ‘Orange’], };
How do I destructure each property of the colors object using a for loop?
Normally without using loops I could do it this way:
const [primaryColors, secondaryColors, tertiary Colors] = Object.keys[color];
But the reason why I want to use a loop to achieve this is cuz I want a situation whereby I don’t know the number of properties the objects has. So instead of destructuring them individually, I want to use a loop.