Update snippet descriptions
This commit is contained in:
@ -3,13 +3,13 @@ title: isDateValid
|
||||
tags: date,intermediate
|
||||
---
|
||||
|
||||
Returns `true` if a valid date object can be created from the given values, `false` otherwise.
|
||||
Checks if a valid date object can be created from the given values.
|
||||
|
||||
- Use the spread operator (`...`) to pass the array of arguments to the `Date` constructor.
|
||||
- Use `Date.prototype.valueOf()` and `Number.isNaN()` to check if a valid `Date` object can be created from the given values.
|
||||
|
||||
```js
|
||||
const isDateValid = (...val) => !isNaN(new Date(...val).valueOf());
|
||||
const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf());
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user