Chrome 控制台错误?

Chrome console bug?

这个问题没有任何疑问和问题。显然,我似乎在 chrome 控制台上偶然发现了一个错误,

我使用这个代码:

console.log("Before: ", this.selectedScorecard.scorecard_attributes);
let attribute = this.selectedScorecard.scorecard_attributes.find(item => item.id === null || item.id === undefined)

if(attribute) {
   let length = this.selectedScorecard.scorecard_attributes.length;
   this.selectedScorecard.scorecard_attributes.splice(length-1, 1);
   console.log("After: ", this.selectedScorecard.scorecard_attributes);
}

好的,属性是一个数组,最初是一个长度为 2 的数组。 现在我从数组中拼接一个项目并在拼接前后打印它的值。

在 chrome 控制台中数组之前的代码片段中它显示 (2) 指示长度为 2 但在数组本身中它显示长度为 1 并且 [=23 中也只有一项=] 虽然 "After console" 中的事情显然符合预期 我附上一张图片以便更好地理解

我很好奇,有人对此有任何想法吗?有没有人遇到过这个问题,还是只有我注意到它?

当 console.log 运行时,chrome 会同步注销其中内容的摘要。该数组有 2 个元素,因此摘要记录了 (2)。 Chrome 保留对数组的引用,以防您稍后决定要查看更多数据,但它不会克隆整个数组。

稍后,当您单击展开数组时,它会显示更多详细信息,但它是根据您展开时的样子显示的,而不是日志语句最初出现时的样子。因为它只有 1 个元素,所以它显示的就是这个。