Facing an issue in filter. New in javascript. I can explain the problem with an example. Here is an example I have three arrays of different size and objects I want to get the common object of them all
var arrays = [
[
{
"id": "5",
"Name" : "Actor 5"
}
],
[
{
"id": "5",
"Name" : "Actor 5"
},
{
"id": "6",
"Name" : "Actor 6"
}
],
[
{
"id": "3",
"Name" : "Actor 3"
},
{
"id": "4",
"Name" : "Actor 4"
},
{
"id": "5",
"Name" : "Actor 5"
}
]
];
The answer should be
[
{
"id": "5",
"Name" : "Actor 5"
}
]
I tried:
var result = arrays.shift().filter(function(v.Name) {
return arrays.every(function(a) {
return a.indexOf(v.Name) !== -1;
});
});