Answers for "find 2 array value in javascript"

0

how to get different values from two arrays js

let difference = arr1
                 .filter(x => !arr2.includes(x))
                 .concat(arr2.filter(x => !arr1.includes(x)));
Posted by: Guest on March-09-2021
1

javascript find matching elements in two arrays

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] }));
Posted by: Guest on May-20-2020

Code answers related to "find 2 array value in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language