This string:
const date = "31/12/2020";
will give an "Invalid Date" if converted to date:
const asDate = new Date(date);
console.log(asDate);
The date above is an american-style date represented as string. Is there any chance javascript can understand dates written in different styles? So basically these:
const date2 = "31/12/2020";
const date = "2020-12-31";
would both give the same date?
12/31/2021. With that said, in either case, it's not a standard string, so you get implementation-dependent behaviour. The date might be parsed as valid (whether or not is the date you actually meant is not a requirement), it might also simply fail. See What are valid Date Time Strings in JavaScript? - only "2020-12-31" is a valid standard-compliant string which will be interpreted unambiguously.