How to skip over an element in .map()?

前端 未结 16 2055
余生分开走
余生分开走 2020-11-27 09:26

How can I skip an array element in .map?

My code:

var sources = images.map(function (img) {
    if(img.src.split(\'.\').pop() === \"json         


        
16条回答
  •  误落风尘
    2020-11-27 10:12

    I use .forEach to iterate over , and push result to results array then use it, with this solution I will not loop over array twice

提交回复
热议问题