Nobrainer actually both are “slow” in comparison to native but definitely isAfter
, isBefore
, isSame
are more expensive than initializing the moment object.
What you’ve proposed could work well, which is preparing the the date objects beforehand but you’ll still need to take into account the performance cost of the comparison(s). Also, preparing the objects beforehand could still take a toll on performance depending on data, and number of dates. It’ll still be more proficient if you use moment for the presentation layer only (if possible) — if your data set is large.