2

The following:

var pointDate = new Date(2009, 00, 01);
var pointSingle = [pointDate,1000];
var pointDataset = [pointSingle];
console.log(pointDate);
console.log(pointSingle);
console.log(pointDataset);

Displays this:

Thu Jan 01 2009 00:00:00 GMT-0800 (Pacific Standard Time)
[Thu Jan 01 2009 00:00:00 GMT-0800 (Pacific Standard Time), 1000]
[Array[2]]
0: Array[2]
0: Invalid Date
1: 1000
length: 2

Does anyone know why the date object becomes and invalid date after be entered into a nested array?

Thanks

Update 1: I tested the same code snippet in a new HTML file, and the issue did not manifest. I don't know why...

user3156154
  • 53
  • 1
  • 4

1 Answers1

1

Working correctly on chrome. This is the code :

var pointDate = new Date(2009, 00, 01);
var pointSingle = [pointDate,1000];
var pointDataset = [pointSingle];
console.log(pointDate);
console.log(pointSingle);
console.log(pointDataset);
// added to debug - but before this also the values were valid ones.
console.log(pointDataset[0]);

enter image description here

ADD

It seems the nested arrays are treated as objects but not arrays at all. Somehow, it is not yet correctly understood of this kind of behavior.

Community
  • 1
  • 1
Siva Tumma
  • 1,695
  • 12
  • 23
  • I am also using Chrome. I edited my code to include console.log(pointDataset[0]); and it correctly displays the date object, just like your code. Problem still persists. – user3156154 Jan 03 '14 at 07:58
  • Others have suggested [this](http://stackoverflow.com/questions/9725299/why-does-chrome-dev-tool-show-a-dates-proto-as-invalid-date). Even though the data contains, since __proto__ is deprecated, it says Invalid Date... also, there is good explanation of something like `date(NAN)`... – Siva Tumma Jan 03 '14 at 08:01