how to determine if date is weekend in javascript
Short and sweet.
var isWeekend = ([0,6].indexOf(new Date().getDay()) != -1);
I tried the Correct answer and it worked for certain locales but not for all:
In momentjs Docs: weekday The number returned depends on the locale initialWeekDay, so Monday = 0 | Sunday = 6
So I change the logic to check for the actual DayString('Sunday')
const weekday = momentObject.format('dddd'); // Monday ... Sunday
const isWeekend = weekday === 'Sunday' || weekday === 'Saturday';
This way you are Locale independent.
var dayOfWeek = yourDateObject.getDay();
var isWeekend = (dayOfWeek === 6) || (dayOfWeek === 0); // 6 = Saturday, 0 = Sunday
var isWeekend = yourDateObject.getDay()%6==0;