-
Notifications
You must be signed in to change notification settings - Fork 1
intersection$
Subhajit Sahu edited this page Jun 12, 2020
·
18 revisions
Gives entries present in both objects. 🏃 📼 📦 🌔 📒
Similar: union, intersection, difference, symmetricDifference, isDisjoint.
object.intersection(x, y, [fn]);
// x: an object
// y: another object
// fn: combine function (a, b)
const map = require('extra-map');
var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4]]);
var y = new Map([['b', 20], ['c', 30], ['e', 50]]);
map.intersection$(x, y);
// Map(2) { 'b' => 2, 'c' => 3 }
x;
// Map(2) { 'b' => 2, 'c' => 3 }
var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4]]);
map.intersection$(x, y, (a, b) => b);
// Map(2) { 'b' => 20, 'c' => 30 }