2019-08-13 树形数据结构转换(未完成) 将[{id:1},{id:2, pId:1},...]转成[id1:child:[{id:2, pid:1}]] 1234567891011121314const fn = arr => { const res = [] const map = arr.reduces((res, item) => ((res[item.id] = item), res), {}) for (const item of Object.values(map)) { it(!item.pId) { res.push(item) } else { const parent = map[item.pId] parent.child = patent.child || [] parent.child.push(item) } } return res;} Newer 统计 1 ~ n 整数中出现 1 的次数(未完成) Older HTTP状态码