Removing duplicate array values and then storing them [react]

前端 未结 5 637
Happy的楠姐
Happy的楠姐 2021-02-06 16:49

I\'m trying to strip the duplicate array values from my current array. And I\'d like to store the fresh list (list without duplicates) into a new variable.

var          


        
5条回答
  •  再見小時候
    2021-02-06 17:15

    you forgot to use return statement in the filter call

    const namesArr = duplicatesArray.filter(function(elem, pos) {
        return duplicatesArray.indexOf(elem) == pos;
    }); 
    

提交回复
热议问题