function isWeekend(dateString) {
const date = new Date(dateString);
const day = date.getDay(); // 0是周日,6是周六
if (day === 0 || day === 6) {
return "周末";
} else {
return "工作日";
}
}
console.log(isWeekend("2024-07-20")); // 输出:周末
console.log(isWeekend("2024-07-22")); // 输出:工作日
利唐i人事HR社区,发布者:hi_ihr,转转请注明出处:https://www.ihr360.com/hrnews/20241211280.html