Given dayNumber
is from 0
- 6
representing Monday
- Sunday
respectively.
Can the Date
/
let weekday = ['Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'][new Date().getDay()];
console.log(weekday)
This will add a getDayOfWeek() function as a prototype to the JavaScript Date class.
Date.prototype.getDayOfWeek = function(){
return ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][ this.getDay() ];
};