arr.reduce(callback(accumulator, currentValue[, index[, array]])[, initialValue])
var DICT_ARRAY= [
{
dictType: 718,
dictParentCode: 'PROJECT_STAGE'
},
{
dictType: 22,
dictParentCode: 'OPP_CATEGORY'
},
];
let params = DICT_ARRAY.reduce((previousValue, item) => {
console.log('previousValue==',previousValue)
console.log('item==',item)
if (previousValue) {
previousValue = previousValue + '&';
}
return `${previousValue}typeAndParentCodes=${item.dictType}<@>${item.dictParentCode}`;
}, '');
console.log('params==',params)
VM5388:14 previousValue== ''
VM5388:15 item== {dictType: 718, dictParentCode: "PROJECT_STAGE"}
VM5388:14 previousValue== typeAndParentCodes=718<@>PROJECT_STAGE
VM5388:15 item== {dictType: 22, dictParentCode: "OPP_CATEGORY"}
VM5388:21 params== typeAndParentCodes=718<@>PROJECT_STAGE&typeAndParentCodes=22<@>OPP_CATEGORY