```javascript
复制
// Get the current date const currentDate = new Date(); // Get the day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday) const dayOfWeek = currentDate();
// Calculate the start and end dates of the current week const startDate = new Date(currentDate); startDate.setDate(currentDate.getDate() - dayOfWeek); const endDate = new Date(startDate); endDate.setDate(startDate.getDate() 6);
// Print the start and end dates of the current week console.log("Start date of the week: " startDateDateString()); console.log("End date of the week: " endDate.toDateString());
```
这段代码将输出本的开始日期和结束日期。