I have 2 objects like this:
var customerA = {firstName: "Dravid, Tendulkar"},
customerB = {firstName: "Virendra, Virat, Tendulkar"};
I want to find same names from those strings and merge them by using Proxy, but I can't go further more than this:
var customerA = {firstName: "Dravid, Tendulkar"},
customerB = {firstName: "Virendra, Virat, Tendulkar"};
var proxyMerge = new Proxy([customerA, customerB], {
get: (target, keyName) => {
let arr = target.map(item => item[keyName]);
let output = arr.filter(item => arr[item] == arr.includes(item)); // returns an empty array.
return output;
}
})
var customers = proxyMerge.firstName;
console.log(customers); // the output should be: ["Dravid, Tendulkar, Virendra, Virat"]
How can I get a complete array has no same names?