Using lodash to check whether an array has duplicate values

前端 未结 6 669
独厮守ぢ
独厮守ぢ 2020-12-30 21:57

What do you all think would be the best (best can be interpreted as most readable or most performant, your choice) way to write a function using the lodash utilities in orde

6条回答
  •  粉色の甜心
    2020-12-30 22:29

    Well, there's always. lodash's _.uniq() function. That function actually returns a new array that only contains unique values, so checking to see if the length of the array has changed would get you your 'true' or 'false' value to return yourself, I believe.

提交回复
热议问题