gpt4 book ai didi

javascript - 奇怪的是,window.document 没有返回理想情况下应该返回的正确对象。为什么?

转载 作者:行者123 更新时间:2023-12-03 09:52:06 24 4
gpt4 key购买 nike

情况一:(任何一般对象)

Obj1 = {
name: "Jack",
age: 21,
address: {
city: "New York",
street: "Black Street",
house_no: 39
}
}

现在,在 console.log(Obj1.address)我会得到:

 {
city: "New York",
street: "Black Street",
house_no: 39
}

案例二:Window.document

应用相同的逻辑 - 首先我会做 console.log(window) ,然后console.log(window.document) 。但是,现在我没有得到 window.document 的正确结构(理想情况下我应该得到),而是得到“dom-struct”(理想情况下我不应该得到)。

现在,有人可以告诉我为什么会发生这种情况吗?如何在 window.document 中获得正确的结构而不是 html dom?

console.log(窗口);

enter image description here

console.log(window.document);

enter image description here

Now, Can someone please help me understand the issue of why 'window.document' is not providing proper structure of object -- which it should?

最佳答案

当您 console.log 任何 DOM 元素时,Chromium 将在控制台中显示该元素的 HTML 结构。如果您想检查对象的 Javascript 属性,则必须使用 console.dir:

enter image description here

(这样做的主要缺点是 console.dir 只接受一个对象作为参数,但 console.log 可以一次记录多个参数)

关于javascript - 奇怪的是,window.document 没有返回理想情况下应该返回的正确对象。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60703668/

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