How to validate a date in JavaScript

This blog is about how to check if a string value in “yyyymmdd” format is valid date. The TypeScript code below is the function that I have created.

The function returns true only if the date exists on the calendar.