Skip to content

isDate ​

The isDate function checks if the provided value is an instance of Date.

Syntax ​

typescript
isDate(value: any): value is Date;

Parameters ​

ParameterTypeDescription
valueanyValue to be checked

Returns ​

TypeDescription
booleanTrue if it is an instance of Date

Examples ​

typescript
isDate(new Date()); // => true
isDate("2024-01-01"); // => false

Notes ​

  • Useful for validating dates before performing operations with Date objects.

References ​

Released under the MIT License.