I have this script,
var today = new Date();
var dd = today.getDate();
var ffffd = today.getDate()-1;
var ffffdd = today.getDate()-2;
var mm = today.getMonth()+
You can do it like this
//one day previous Date
var date = new Date();
date.setDate(date.getDate() - 1);
console.log(date.getDay());
//for previous month last date
var date = new Date();
date.setDate(0);
console.log(date);
//for perivous Month First date
var date = new Date();
date.setDate(0);
date.setDate(1);
console.log(date);