Underscore.js - get unique property values

后端 未结 5 1981
我寻月下人不归
我寻月下人不归 2021-02-13 18:12

I only recently discovered the power of underscore.js, still new to the methods I kindly ask for a suggestion:

How do I get from this:

[
    [{
                 


        
5条回答
  •  广开言路
    2021-02-13 18:18

    _(data).chain().flatten().pluck('name').unique().value()
    

    (Convert the nested lists to a flat one, pick name from each of the objects in the list, and make it unique.)

提交回复
热议问题