Short answer:
This is the misuse of the browsers you mention.
You must check the date in the correct format yourself. But this is pretty trivial, I propose this approach:
Separate the date in year y , month m , day d and create a Date object:
var date = new Date( y, m - 1, d );
Then compare the original values ββwith the boolean values ββobtained using the Date methods:
var isValid = date.getDate() == d && date.getMonth() == m-1 && date.getFullYear() == y;
Before doing all this, you can check the correctness of the date string for any browser:
Invalid Date Detection JavaScript Date Instance
Long answer:
Firefox (and IE), accepting "2/8888/2016" as the correct string format, seems like an error / incorrect behavior.
In fact, according to the ECMAScript 2015 Language Specification, when Date() is called with one argument of a string, it should behave like Date.parse()
http://www.ecma-international.org/ecma-262/6.0/#sec-date-value
Last
tries to analyze the format of the string in accordance with the rules (including long years), is called in the format of the date time string (20.3.1.16)
.. which is listed here
http://www.ecma-international.org/ecma-262/6.0/#sec-date-time-string-format
where can you read
The format is as follows: YYYY-MM-DDTHH: mm: ss.sssZ
[...]
MM - month of the year from 01 (January) to 12 (December).
DD is the day of the month from 01 to 31.
Firefox seems to interpret the string value as if calling Date() with several arguments.
FROM
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Note. . If Date is called as a constructor with several arguments, if values ββare greater than their logical range (for example, 13 is provided as the value of the month or 70 for the minute value), the adjacent value will be adjusted. For example. the new date (2013, 13, 1) is equivalent to the new date (2014, 1, 1), both create a date for 2014-02-01 (note that the month is based on 0). Similarly for other values: the new date (2013, 2, 1, 0, 70) is equivalent to the new date (2013, 2, 1, 1, 10), which creates a date for 2013-03-01T01: 10: 00.
This may explain how "2/8888/2016" turns into 2040-05-31T22:00:00.000Z