在控制台中打印数组时长度错误

Getting a wrong length when printing an array in console

在对数组执行 console.log 时,我得到以下结果:

第一张图片(顶部)中的数字 (25) 代表什么?我的数组的长度是 27,而不是 25。我认为这是非 null 值的计数,但第二张图片却不是这样。

(25) 和 (27) 也以简化形式存在:

这在 Firefox 和 Chrome 中都会发生。

导致此行为的代码:

var lows = ts2values[current_ts];
var highs = ts2values[current_ts];

console.log("lows b : ", lows);
console.log("highs b : ", highs);

lows.push(null);
highs.push(null);

console.log("lows a : ", lows);
console.log("highs a : ", highs);

What does the number (25) represent in the first picture (at the top)?

当时数组的长度.

你可以通过下面的代码看到同样的结果。

myArray = [1, 2, 3]
console.log(myArray)

myArray.push(4, 5, 6)
console.log(myArray)

第一个日志是Array(3)

并且展开第一个日志,数组的长度是6,不是3,因为是在console.log

之后更新的