Strange error with date, "unverified illegal access"

So, I tried to find the last Dateone that can handle Javascript.

I got to September 275760 and increased the days when I started getting an exception illegal accessfrom illegal accessfrom new Date('09/24/275760')to new Date('10/13/275760'). Before new Date('09/24/275760'), it new Dateworked fine and gave it to me Invalid Date, and after new Date('10/13/275760')that, new Dateit started working normally again and gave it to me Invalid Date.

I looked at the error stack and it came from the command line interface, which was not very useful (except for the fact that it meant that the error came from the internal code).

So the question is, why is it new Datethrowing an error instead of following the specific behavior of the grant Invalid Dateon these specific dates?

I am running Chrome 43.0.2357.81 (64-bit) (Official Build) on Mac OSX Yosemite (10.10.3).

Edit

This only happens when I use strings (EX:) new Date('10/01/275760'). See JSFiddle . However, when using integer arguments (EX:), new Date(275760, 10, 1)it works fine. Thanks to @abhitalks for finding this.

+3
source share
1 answer

​​:

var dt = new Date(8640000000000000)

var dt0 = new Date(275760, 8, 13);
var dt1 = new Date(275760, 9, 13);
var dt2 = new Date(275760, 9, 14);
var dt3 = new Date(8640000000000000);
var dt4 = new Date('275760-9-13');

console.log(dt0); // Sat Sep 13 275760 00:00:00 GMT
console.log(dt1); // Invalid Date (Reads October, 0-based month)
console.log(dt2); // Invalid Date
console.log(dt3); // Sat Sep 13 275760 05:30:00 GMT
console.log(dt4); // Sat Sep 13 275760 00:00:00 GMT
+5

Source: https://habr.com/ru/post/1675726/


All Articles