16 lines
402 B
Markdown
16 lines
402 B
Markdown
---
|
|
title: isSameDate
|
|
tags: date,utility,beginner
|
|
---
|
|
|
|
Check if a date is the same as another date.
|
|
|
|
Use `Date.prototype.toISOString()` and strict equality checking (`===`) to check if the first date is the same as the second one.
|
|
|
|
```js
|
|
const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString();
|
|
```
|
|
|
|
```js
|
|
isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true
|
|
``` |