Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 659 Bytes

isWeekday.md

File metadata and controls

26 lines (17 loc) · 659 Bytes
标题 标签
isWeekday(是否是工作日) type(类型)

检查给定日期是否为工作日。

  • 使用 Date.prototype.getDay() 通过取模运算符 (%) 检查工作日。
  • 省略参数 d 以使用当前日期作为默认值。
const isWeekday = (d = new Date()) => d.getDay() % 6 !== 0;

调用方式:

isWeekday(); // true (if current date is 2022-11-03)

应用场景

结果如下:

<iframe src="codes/javascript/html/isWeekday.html"></iframe>