What is a good way of achieving this filtering?

I have data like the following: var data = [{ id: 1, date: new Date("2010-01-01"), value: 10 }, { id: 2, date: new Date("2010-01-01"), value: 11 }, { id: 3, date: new Date("2010-01-01"), value: 12 }, { id: 4, date: new Date("2010-01-02"), value: 10 }, { id: 5, date: new Date("2010-01-03"), value: 10 }, { id: 6, date: new Date("2010-01-03"), value: 21 }, { id: 7, date: new Date("2010-01-03"), value: 22 }, { id: 8, date: new Date("2010-01-03"), value: 23 }]; I am trying to apply two kinds of filters: - `Filter1` should give me only those points that differ by 1 in their `value` field but having the same `date` field. Therefore, this should return a new dataset containing data records with ids 1,2,3, 6,7,8 (the first three because values are 10,11,12 and last three because values are 21,22,23) - `Filter2` should give me only those points that differ by 1 day in their `date` field but having the same `value` field. Therefore, this should return a new dataset containing data records with ids 1,4,5 I am currently doing this in C# on the server-side but am looking to see if there is an efficient way to do this in Javascript. Any suggestions?

以上就是What is a good way of achieving this filtering?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏