function getPagesArr(pages, categories) { var map = categories.reduce((m, c) => (m.set(c._id, c.catClass), m), new Map()); return pages.map((p) => { var v = Object.assign({}, p); v.ctgrId = map.get(p.ctgrId) || p.ctgrId; return v; }); }