I was recently implementing a calendar component on a UI and it required an array of dates to initialize it. I wanted to show the last 90 days. MomentJS has some neat utility libraries built on it that I have used before that would have fit the bill. However, I didn't want to introduce that whole library for this one problem.

I came up with a solution that only used the native JS date libraries. JavaScript strangely allows arithmetic on date objects. If you do something like new Date() + 1, it will give you the current time but with tomorrows date.