Create new array by filter origin array I'm getting an array and I needed to find a duplicate ID inside:

var aDuplicateId = [];
            //get the duplicated configuration indexs
            for (var i = 0; i &lt; aConfigurations.length; i++) {
                //in case the index is the duplicate array skip
                if (aDuplicateId.indexOf(i) &gt;= 0) {
                    continue;
                }
                var iId = aConfigurations[i]._metadata.id;
                //find duplicate ids
                var iIndex = _.findLastIndex(aConfigurations, function(o) {
                    return o._metadata.id === iId;
                });
                //add the duplicate id index to array
                if (iIndex &gt;= 0 &amp;&amp; iIndex !== i) {
                    aDuplicateId.push(iIndex);
                }
            }
So essentially, you're just getting the unique configuration IDs. This can easily be done by converting your aConfigurations into an array of IDs and using Set to weed out duplicates. Then you can convert the set instance back into an array using Array.from.

const configIds = aConfigurations.map(config =&gt; config._metadata.id);
const configIdsSet = new Set(configIds);
const configIdsUnique = Array.from(configIdsSet);


Alternatively, without ES6, you can just use array.reduce to collect IDs as keys of an object and then use Object.keys to extract the keys into an array.

var configMap = aConfigurations.reduce(function(configs, config){
  configs[config._metadata.id] = true;
  return configs;
}, {});

var configIdsUnique = Object.keys(configMap);