Get start and end of current hour in javascript

javascript
const date = new Date();
const d1 = new Date(
  date.getFullYear(),
  date.getMonth(),
  date.getDay(),
  date.getHours(),
  0,
  0,
  0,
);
const d2 = new Date(
  date.getFullYear(),
  date.getMonth(),
  date.getDay(),
  date.getHours(),
  59,
  59,
  999,
);

console.log(d1); // 2021-03-05T09:00:00.000Z
console.log(d2); // 2021-03-05T09:59:59.999Z