[Vuejs]-How to iterate one loop on multiple object in javascript or vue

0👍

You can merge thus object into one and than iterate over it, like this:

for (let route of [].concat(contactRoutes, userRoutes, customerRoutes)) {
    baseRoutes[0].children.push(route);
}

This way you are interating over all your objects at once.

To use exported objects dynamically without specifing each one you can do something like this:

const allRoutes = [].concat(...Object.values(adminRoutes));
for (let route of allRoutes) {
    baseRoutes[0].children.push(route);
}

Leave a comment