Here ya go:
function intersectionWith() {
var comparator = arguments[arguments.length - 1];
var others = [].slice.call(arguments, 1, arguments.length - 1);
var first = arguments[0];
var results = [];
first.forEach(function(item) {
if (results.find(function(result) { return comparator(item, result) })) {
return;
}
if (others.every(function(other) {
return other.find(function(otherItem) {
return comparator(item, otherItem);
});
})) {
results.push(item);
}
});
return results;
}
And here it is in action with a shallow equal function: https://jsfiddle.net/shiftyp/7jevjxjr/