const array = [0, 1, 2, 3]; // фильтров нужно столько же, сколько элементов в массиве
const baseFilter = {
name1: 111,
name2: 222,
};
const objData = {
multiple: {
filter: {
...baseFilter,
prop: 0,
},
filter2: {
...baseFilter,
prop: 1,
},
filter3: {
...baseFilter,
prop: 2,
},
},
};
const obj = array.reduce((acc, n, i) => (
acc[`filter${i + 1}`] = { ...baseFilter, prop: n },
acc
), {});
const obj = {};
for (const [ i, n ] of array.entries()) {
(obj['filter' + (-~i)] = Object.assign({}, baseFilter)).prop = n;
}
const obj = {};
for (let i = 0; i < array.length;) {
const subobj = { prop: array[i] };
for (const k in baseFilter) {
subobj[k] = baseFilter[k];
}
obj['filter'.concat(++i)] = subobj;
}