underscore.js - Is there a function that produces an array thats the difference of two arrays?

前端 未结 4 1067
难免孤独
难免孤独 2021-02-04 03:28

Looking for a function in underscore.js that will take 2 arrays and return a new array of unique values? Something like _without

_.without([0, 1, 3, 9], [1, 3])         


        
4条回答
  •  一向
    一向 (楼主)
    2021-02-04 04:02

    The _.difference function should give you what you're looking for:

    _.difference([0, 1, 3, 9], [1, 3]); // => [0, 9]
    

提交回复
热议问题