You can use JavaScript Date objects and a while loop.
Just subtract a month from the current month till you get to the date you want.
Something like this should work.
https://jsfiddle.net/wsf61jpk/5/
var date="December 2018";
var result=[];
//set both start and end date to first date of the month
const end_date = new Date(date.replace(" ", " ,1 "));
const start_date = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
while(end_date<=start_date){
result.push(start_date.toLocaleString('default', { month: 'long' , year: 'numeric'}));
start_date.setMonth(start_date.getMonth() - 1);
}
console.log(result);