javascript

Util Array Examples

const allLanguages = [ 'ES', 'EN', 'DE' ]
const usedLanguages = [ { id: 1, lang: 'EN' } ].map(e => e.lang);

var result = allLanguages.filter(e => !usedLanguages.includes(e));
console.log(result)


=================



 const myArrayFiltered = this.AllGroupActive.filter(array => this.workFrontAnomalyType.developmentStageGroupId.some(filter => filter === array.id ));
 const checkAllActive = myArrayFiltered.every(item => item.active);



 ===========================================================
var arr1 = ['a', 'b'];
var arr2 = ['a', 'b', 'c', 'd'];

  let intersection = arr1.filter(x => arr2.includes(x));
  let difference = arr1.filter(x => !arr2.includes(x));

   symmetric difference,

   let difference = arr1
                 .filter(x => !arr2.includes(x))
                 .concat(arr2.filter(x => !arr1.includes(x))); 
=======================

someValues.forEach((element, index) => {
    console.log(`Current index: ${index}`);
    console.log(element);
});

============

 removeAnomaly(anomaly: WorkFrontAnomaly){
        var index = this.workFrontAnomalies.indexOf(anomaly);

        if(index != -1){
            this.workFrontAnomalies.splice(index, 1);
        }
    }
Was this helpful?