Skip to main content

Check if a date is a weekend

JavaScript version

// `date` is a Date object
const isWeekend = (date = new Date()) => date.getDay() % 6 === 0;

TypeScript version

const isWeekend = (date = new Date()): boolean => date.getDay() % 6 === 0;

Comments