Following is the scenario:
I have a String date and a date format which is different. Ex.: date: 2016-10-19 dateFormat: \"DD-MM-YYYY\".
String
I use moment along with new Date to handle cases of undefined data values:
undefined
const date = moment(new Date("2016-10-19"));
because of: moment(undefined).isValid() == true
moment(undefined).isValid() == true
where as the better way: moment(new Date(undefined)).isValid() == false
moment(new Date(undefined)).isValid() == false