how to find duplicate item from array using multiple object keys in angular or javascript

 how to find duplicate item from array using multiple object keys


There is a way to find based of multiple key find duplicate records in angular or javascript

 
getDuplicate(itemskeys) {
        let duplicates = [];
        for (let i = 0i < items.lengthi++) {
            let matchkey = 0;
            for (let j = 0j < keys.lengthj++) {
                if ((i < (items.length - 1)) && items[i + 1][keys[j]].toLowerCase() === items[i][keys[j]].toLowerCase()) {
                    matchkey++;
                }
            }
            if (matchkey === keys) {
                duplicates.push(items[i]);
            }
        }
        return duplicates;
    }

Example:
const duplicatethis.getDuplicate(CounterParty, ['OperatorId''TCID']);

















No comments:

Post a Comment

Thank You For Your Great Contribution

Featured Post

how to find n number of nodes have child or cildren

 how to find n number of nodes have child or cildren for that we use recursive function  const   data = {     'id' : '0' ,...

Popular Posts