Array Of JS Dates How To Group By Days

前端 未结 4 1472
旧时难觅i
旧时难觅i 2020-12-05 18:10

I\'m trying to figure out the most optimal and with as minimum amount of loops way to group my array of js dates objects from this: (Take a note this is browser console outp

4条回答
  •  被撕碎了的回忆
    2020-12-05 18:25

    Why do need this optimization? If your array is not large enoguh than you probably don't need to optimize your algorithm.

    I am not familiar with the given js libraries, but you can group your array by days with one loop. But you need to somehow determine the current day in the array and then create corresponding js object with a day-field and a times-array field and then add this object to your resulting array. It will be much faster if you presort your array before implementing this algorithm.

提交回复
热议问题