comparing items in an array javascript code example

Example 1: check array values equal js

[1,1,1,1].every( (val, i, arr) => val === arr[0] )   // true

Example 2: 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] }));