以下内容:
var pointDate = new Date(2009, 00, 01);
var pointSingle = [pointDate,1000];
var pointDataset = [pointSingle];
console.log(pointDate);
console.log(pointSingle);
console.log(pointDataset);
显示:
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
有人知道日期对象变成嵌套数组后的原因和无效日期吗?
由于
更新1:我在新的HTML文件中测试了相同的代码段,但问题没有显现出来。我不知道为什么......
答案 0 :(得分:1)
在chrome上正常工作。这是代码:
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]);
添加强>
似乎嵌套数组被视为对象,但根本不是数组。不知何故,尚未正确理解这种行为。