Filtering through a multidimensional array using underscore.js

后端 未结 4 1632
-上瘾入骨i
-上瘾入骨i 2021-01-12 05:58

I have an array of event objects called events. Each event has markets, an array containing market objects.

4条回答
  •  被撕碎了的回忆
    2021-01-12 06:13

    Try this:

    _.filter(events, function(me) { 
        return me.event && 
            me.event.market && me.event.market.outcome && 
            'test' in me.event.market.outcome
    }); 
    

    DEMO

提交回复
热议问题