It always makes me nervous using Date objects with arithmetic as if they are integers. I know it is supposed to work, but it would be cleaner to just not use Dates here at all.  Just 

var yesterday = Date.now()  - 24*60*60*1000