find all the days in a month with date object
function getDayNamesInMonth(month, year) { let date = new Date(year, month, 1); let days = []; while (date.getMonth() === month) { days.push(new Date(date).toLocaleDateString('en-US', { weekday: 'short' })); date.setDate(date.getDate() + 1); } return dayNames; }
get all days from selected month and year
const getDaysInMonth = (month, year) => (new Array(31)).fill('').map((v,i)=>new Date(year,month-1,i+1)).filter(v=>v.getMonth()===month-1)
Source: stackoverflow.com