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...

3
  • 1
    Possible duplication of stackoverflow.com/questions/9725299/… Commented Jan 3, 2014 at 6:53
  • 1
    I can't reproduce this behavior. What browser are you testing this on? Commented Jan 3, 2014 at 7:02
  • I am testing using Chrome Version 31.0.1650.63 m Commented Jan 3, 2014 at 8:00

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
Others have suggested this. Even though the data contains, since proto is deprecated, it says Invalid Date... also, there is good explanation of something like date(NAN)...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.