zantop's recent timeline updates
zantop

zantop

V2EX member #327177, joined on 2018-07-05 18:36:43 +08:00
zantop's recent replies
@deppindeepin 坦白了 21🌚
@sunjourney 这个回答我给你满分💯,哈哈
我也是这么想的
我是忘了指定 IdentityFile
Jun 26, 2019
Replied to a topic by Colorful 程序员 请教一个数组合并的问题
const arr1 = [
{ id: '150', name: '李三' },
{ id: '151', name: '李三 1' },
{ id: '152', name: '李三 2' },
{ id: '153', name: '李三 3' }
];

const arr2 = [
{ sname: '一级', otor: ['李三 1', '150'] },
{ sname: '一级 2', otor: ['李三 2'] },
{ sname: '一级 3', otor: ['153'] }
];

arr2.map((item, index) => {
const temArr = [];
item.otor.map((ele, idx) => {
const ar = arr1.filter((a, b) => ele === a.id || ele === a.name);
if (ar.length > 0) {
temArr.push(ar[0]);
}
});
item.otor = temArr;
});
console.log(arr2)
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2802 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 12:08 · PVG 20:08 · LAX 05:08 · JFK 08:08
♥ Do have faith in what you're doing.