📌  相关文章
📜  javascript 在两个数组中查找匹配的元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:30.192000             🧑  作者: Mango

代码示例2
let firstArray = ["One", "Two", "Three", "Four", "Five"];
let secondArray = ["Three", "Four"];

let map = {};
firstArray.forEach(i => map[i] = false);
secondArray.forEach(i => map[i] === false && (map[i] = true));
let jsonArray = Object.keys(map).map(k => ({ name: k, matched: map[k] }));