try adding they apply method:
var myArr = [
[
{"name":"product1","light":"1"},
{"name":"product2","light":"2"},
{"name":"product5","light":"5"},
{"name":"product4","light":"4"}
],
[
{"name":"product2","light":"2"},
{"name":"product3","light":"3"},
{"name":"product4","light":"4"}
]
]
_.intersectionObjects = _.intersect = function(array) {
var slice = Array.prototype.slice;
var rest = slice.call(arguments, 1);
return _.filter(_.uniq(array), function(item) {
return _.every(rest, function(other) {
return _.any(other, function(element) {
return _.isEqual(element, item);
});
});
});
};
var myIntersection = _.intersectionObjects.apply(_, myArr);
for (var i = 0; i < myIntersection.length; i++) {
console.log(myIntersection[i]);
}
// Sample Output:
// Object {name: "product2", light: "2"}
// Object {name: "product4", light: "4"}