Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JavaScript convert for loops to ES6/ES7

I’m asking little naive question, but I’m seriously I’m not sure how to convert this for loops

const filteredData = csiList.filter(item => {
        for (var i = 0, len = this.tableData.length; i < len; i++) {
          if (this.tableData[i].csiId == item.appId) {
            return false;
          }
        }
        return true;
      })

If some one can quickly show how this loops are/is written in more next gen JS ES6/ES7 way, would be of great help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

const filteredData = csiList.filter(item => !this.tableData.some(tableDataItem => tableDataItem.csiId === item.appId));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading