-
Notifications
You must be signed in to change notification settings - Fork 3
Intersect
Yasser Moradi edited this page Aug 24, 2015
·
1 revision
Description:
This method using 2 collections as an argument, It returns items which exists in both collections. If an element is present in only one of the them method then it will be removed.
Sample:
let set1 = ['A', 'a', 'B', 'C', 'D', 'D', 'E'];
let set2 = ['a', 'B', 'C', 'D', 'E', 'e', 'F'];
let intersectionWithoutComparer = set1.asEnumerable().intersect(set2).toArray();
console.log('Intersect method without comparer');
for (var index = 0; index < intersectionWithoutComparer.length; index++)
console.log(intersectionWithoutComparer[index]);
console.log('Intersect method with comparer');
let intersectWithComparer = set1.asEnumerable().intersect(set2, (a, b) => a.toLowerCase() === b.toLowerCase())
.toArray();
for (var index = 0; index < intersectWithComparer.length; index++)
console.log(intersectWithComparer[index]);