Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-20 23:02:01 +03:00
parent 52880f08ee
commit caa67e2a49
63 changed files with 175 additions and 126 deletions

View File

@ -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