// 周末 查最近的周末
var date6 = new Date();
while (date6.getDay() !== 6) date6.setDate(date6.getDate() - 1);
console.log('date6 ')
var date7 = new Date();
while (date7.getDay() !== 0) date7.setDate(date7.getDate() - 1);
console.log('date7 ')
getDay() 方法可返回一周(0~6)的某一天的数字。注意: 星期天为 0, 星期一为 1, 以此类推。
image.png