gpt4 book ai didi

javascript - Chrome devtools 显示未定义但值存在飞出

转载 作者:行者123 更新时间:2023-11-29 19:09:45 26 4
gpt4 key购买 nike

遇到一个奇怪的问题。我 console.log 一个对象。正如您在图片中看到的,on object 是未定义的,但是当我将它翻出来时,您可以看到它有一个数组。

如果我使用 console.log obj.matchcvs 我得到未定义

enter image description here

这怎么可能? Chrome 开发工具中的错误?

最佳答案

当您在开发工具中单击对象并“打开”它时,chrome 会显示它的当前状态。但是当对象以“短”版本显示时,仅显示在调用 console.log 函数时创建的对象的快照版本。

(function(){
var a = { x: 0 };
// Log variable "a", current snapshot is saved
console.log(a);

// Now modify the variable
a.x = 1;
})()

尝试在您的开发工具中运行此代码,您将看到“短”版本显示属性 x 设置为 0 的对象,当您打开它时,属性 x 设置为 1。这是因为创建快照时,属性 x 设置为 0。

关于javascript - Chrome devtools 显示未定义但值存在飞出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39934019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com