Answers for "compare two arrays and return common values javascript"

10

get common values from two arrays javascript

let intersection = arrA.filter(x => arrB.includes(x));
Posted by: Guest on March-31-2020
1

javascript find matching elements in two arrays

const intersection = array1.filter(element => array2.includes(element));
Posted by: Guest on June-25-2020
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 "compare two arrays and return common values javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language