79264004

Date: 2024-12-09 06:20:35
Score: 1.5
Natty:
Report link

There is now a Set.prototype.intersection function. See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection

// Lets say you have 2 arrays
const arr1 = [1,3,5,7,9,1];
const arr2 = [1,4,9,1,9];

//convert them to Sets
const set1 = new Set(arr1);
const set2 = new Set(arr2);

console.log(set2.intersection(set1)); // Set(2) { 1, 9 }

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Der Alex