Really - window.document and document inside window is not the same. Chrome

Multi tool use
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I wonder why one and the same entity has a different representation inside browser window
object called in console:
- If we call just
window
inside browser console we'll have a whole browser info. Where thedocument
will be represented as object-liked entity included various props and functions (including DOM). - If we call
document
directly bywindow.document
command we'll have just only the DOM representation of it.
So, why does it happen? I really cannot figure out.
Thanks.
javascript

|
show 3 more comments
I wonder why one and the same entity has a different representation inside browser window
object called in console:
- If we call just
window
inside browser console we'll have a whole browser info. Where thedocument
will be represented as object-liked entity included various props and functions (including DOM). - If we call
document
directly bywindow.document
command we'll have just only the DOM representation of it.
So, why does it happen? I really cannot figure out.
Thanks.
javascript

Possible duplicate of What is the difference between window, screen, and document in Javascript?
– devlin carnate
Jan 3 at 21:46
1
No, it's a fully different question. @devlincarnate
– Max Travis
Jan 3 at 21:47
@devlincarnate this is a different question. Delete your duplication mark in my post! I'm not asking about dimensions of the DOM, instead I'm wonder about differents in document and window.document!
– Max Travis
Jan 3 at 21:51
I don't know the proper answer but I assume it is just a matter of interpretation. Chrome developers just assumed that in console, when you typedocument
you want to see the DOM, whereas if you want all info you just typewindow.document
.
– Oliver Tušla
Jan 3 at 21:54
@OliverTušla haha, just type the what you wrote above -window.document
and you will be wonder by what you see in console.... You don't right
– Max Travis
Jan 3 at 21:56
|
show 3 more comments
I wonder why one and the same entity has a different representation inside browser window
object called in console:
- If we call just
window
inside browser console we'll have a whole browser info. Where thedocument
will be represented as object-liked entity included various props and functions (including DOM). - If we call
document
directly bywindow.document
command we'll have just only the DOM representation of it.
So, why does it happen? I really cannot figure out.
Thanks.
javascript

I wonder why one and the same entity has a different representation inside browser window
object called in console:
- If we call just
window
inside browser console we'll have a whole browser info. Where thedocument
will be represented as object-liked entity included various props and functions (including DOM). - If we call
document
directly bywindow.document
command we'll have just only the DOM representation of it.
So, why does it happen? I really cannot figure out.
Thanks.
javascript

javascript

edited Jan 3 at 21:48
Max Travis
asked Jan 3 at 21:42
Max TravisMax Travis
240114
240114
Possible duplicate of What is the difference between window, screen, and document in Javascript?
– devlin carnate
Jan 3 at 21:46
1
No, it's a fully different question. @devlincarnate
– Max Travis
Jan 3 at 21:47
@devlincarnate this is a different question. Delete your duplication mark in my post! I'm not asking about dimensions of the DOM, instead I'm wonder about differents in document and window.document!
– Max Travis
Jan 3 at 21:51
I don't know the proper answer but I assume it is just a matter of interpretation. Chrome developers just assumed that in console, when you typedocument
you want to see the DOM, whereas if you want all info you just typewindow.document
.
– Oliver Tušla
Jan 3 at 21:54
@OliverTušla haha, just type the what you wrote above -window.document
and you will be wonder by what you see in console.... You don't right
– Max Travis
Jan 3 at 21:56
|
show 3 more comments
Possible duplicate of What is the difference between window, screen, and document in Javascript?
– devlin carnate
Jan 3 at 21:46
1
No, it's a fully different question. @devlincarnate
– Max Travis
Jan 3 at 21:47
@devlincarnate this is a different question. Delete your duplication mark in my post! I'm not asking about dimensions of the DOM, instead I'm wonder about differents in document and window.document!
– Max Travis
Jan 3 at 21:51
I don't know the proper answer but I assume it is just a matter of interpretation. Chrome developers just assumed that in console, when you typedocument
you want to see the DOM, whereas if you want all info you just typewindow.document
.
– Oliver Tušla
Jan 3 at 21:54
@OliverTušla haha, just type the what you wrote above -window.document
and you will be wonder by what you see in console.... You don't right
– Max Travis
Jan 3 at 21:56
Possible duplicate of What is the difference between window, screen, and document in Javascript?
– devlin carnate
Jan 3 at 21:46
Possible duplicate of What is the difference between window, screen, and document in Javascript?
– devlin carnate
Jan 3 at 21:46
1
1
No, it's a fully different question. @devlincarnate
– Max Travis
Jan 3 at 21:47
No, it's a fully different question. @devlincarnate
– Max Travis
Jan 3 at 21:47
@devlincarnate this is a different question. Delete your duplication mark in my post! I'm not asking about dimensions of the DOM, instead I'm wonder about differents in document and window.document!
– Max Travis
Jan 3 at 21:51
@devlincarnate this is a different question. Delete your duplication mark in my post! I'm not asking about dimensions of the DOM, instead I'm wonder about differents in document and window.document!
– Max Travis
Jan 3 at 21:51
I don't know the proper answer but I assume it is just a matter of interpretation. Chrome developers just assumed that in console, when you type
document
you want to see the DOM, whereas if you want all info you just type window.document
.– Oliver Tušla
Jan 3 at 21:54
I don't know the proper answer but I assume it is just a matter of interpretation. Chrome developers just assumed that in console, when you type
document
you want to see the DOM, whereas if you want all info you just type window.document
.– Oliver Tušla
Jan 3 at 21:54
@OliverTušla haha, just type the what you wrote above -
window.document
and you will be wonder by what you see in console.... You don't right– Max Travis
Jan 3 at 21:56
@OliverTušla haha, just type the what you wrote above -
window.document
and you will be wonder by what you see in console.... You don't right– Max Travis
Jan 3 at 21:56
|
show 3 more comments
2 Answers
2
active
oldest
votes
This is just the way chrome's developer tools work. They have a few different formats that they can output information in the console. Dom nodes, which are a type of object, have gotten their own fancy implementation, since they're such a common occurrence in web development. So when you do window.document
, that's the format it chooses to output it.
For other types of objects they output it in a different format, and that's what it's doing when you do window
. It's true you can expand this to drill into window.document, but the dev tools keep displaying it in the same format, rather than trying to nest one format inside another.
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
"So when you do window.document, that's the format it chooses to output it." - Useconsole.dir(window.document)
instead ofconsole.log()
– Andreas
Jan 3 at 22:05
@Andreas I don't think he's doing either of those, he's just typingdocument
andwindow.document
directly into the console.
– Barmar
Jan 3 at 22:06
add a comment |
straight from my chrome debugger:
>window.document === document
true
The documentantion relays that window.document is just a reference to document.
However even if they refer to the same document, the document might contain special getters and setters which overide those of window.document...
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
I see what you're saying. Writing justdocument
doesn't access it through the Window object, so it doesn't use the getter/setter.
– Barmar
Jan 3 at 22:17
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030211%2freally-window-document-and-document-inside-window-is-not-the-same-chrome%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is just the way chrome's developer tools work. They have a few different formats that they can output information in the console. Dom nodes, which are a type of object, have gotten their own fancy implementation, since they're such a common occurrence in web development. So when you do window.document
, that's the format it chooses to output it.
For other types of objects they output it in a different format, and that's what it's doing when you do window
. It's true you can expand this to drill into window.document, but the dev tools keep displaying it in the same format, rather than trying to nest one format inside another.
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
"So when you do window.document, that's the format it chooses to output it." - Useconsole.dir(window.document)
instead ofconsole.log()
– Andreas
Jan 3 at 22:05
@Andreas I don't think he's doing either of those, he's just typingdocument
andwindow.document
directly into the console.
– Barmar
Jan 3 at 22:06
add a comment |
This is just the way chrome's developer tools work. They have a few different formats that they can output information in the console. Dom nodes, which are a type of object, have gotten their own fancy implementation, since they're such a common occurrence in web development. So when you do window.document
, that's the format it chooses to output it.
For other types of objects they output it in a different format, and that's what it's doing when you do window
. It's true you can expand this to drill into window.document, but the dev tools keep displaying it in the same format, rather than trying to nest one format inside another.
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
"So when you do window.document, that's the format it chooses to output it." - Useconsole.dir(window.document)
instead ofconsole.log()
– Andreas
Jan 3 at 22:05
@Andreas I don't think he's doing either of those, he's just typingdocument
andwindow.document
directly into the console.
– Barmar
Jan 3 at 22:06
add a comment |
This is just the way chrome's developer tools work. They have a few different formats that they can output information in the console. Dom nodes, which are a type of object, have gotten their own fancy implementation, since they're such a common occurrence in web development. So when you do window.document
, that's the format it chooses to output it.
For other types of objects they output it in a different format, and that's what it's doing when you do window
. It's true you can expand this to drill into window.document, but the dev tools keep displaying it in the same format, rather than trying to nest one format inside another.
This is just the way chrome's developer tools work. They have a few different formats that they can output information in the console. Dom nodes, which are a type of object, have gotten their own fancy implementation, since they're such a common occurrence in web development. So when you do window.document
, that's the format it chooses to output it.
For other types of objects they output it in a different format, and that's what it's doing when you do window
. It's true you can expand this to drill into window.document, but the dev tools keep displaying it in the same format, rather than trying to nest one format inside another.
answered Jan 3 at 21:56
Nicholas TowerNicholas Tower
8,6971925
8,6971925
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
"So when you do window.document, that's the format it chooses to output it." - Useconsole.dir(window.document)
instead ofconsole.log()
– Andreas
Jan 3 at 22:05
@Andreas I don't think he's doing either of those, he's just typingdocument
andwindow.document
directly into the console.
– Barmar
Jan 3 at 22:06
add a comment |
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
"So when you do window.document, that's the format it chooses to output it." - Useconsole.dir(window.document)
instead ofconsole.log()
– Andreas
Jan 3 at 22:05
@Andreas I don't think he's doing either of those, he's just typingdocument
andwindow.document
directly into the console.
– Barmar
Jan 3 at 22:06
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
Thank you for your explanation!
– Max Travis
Jan 3 at 22:02
"So when you do window.document, that's the format it chooses to output it." - Use
console.dir(window.document)
instead of console.log()
– Andreas
Jan 3 at 22:05
"So when you do window.document, that's the format it chooses to output it." - Use
console.dir(window.document)
instead of console.log()
– Andreas
Jan 3 at 22:05
@Andreas I don't think he's doing either of those, he's just typing
document
and window.document
directly into the console.– Barmar
Jan 3 at 22:06
@Andreas I don't think he's doing either of those, he's just typing
document
and window.document
directly into the console.– Barmar
Jan 3 at 22:06
add a comment |
straight from my chrome debugger:
>window.document === document
true
The documentantion relays that window.document is just a reference to document.
However even if they refer to the same document, the document might contain special getters and setters which overide those of window.document...
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
I see what you're saying. Writing justdocument
doesn't access it through the Window object, so it doesn't use the getter/setter.
– Barmar
Jan 3 at 22:17
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
add a comment |
straight from my chrome debugger:
>window.document === document
true
The documentantion relays that window.document is just a reference to document.
However even if they refer to the same document, the document might contain special getters and setters which overide those of window.document...
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
I see what you're saying. Writing justdocument
doesn't access it through the Window object, so it doesn't use the getter/setter.
– Barmar
Jan 3 at 22:17
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
add a comment |
straight from my chrome debugger:
>window.document === document
true
The documentantion relays that window.document is just a reference to document.
However even if they refer to the same document, the document might contain special getters and setters which overide those of window.document...
straight from my chrome debugger:
>window.document === document
true
The documentantion relays that window.document is just a reference to document.
However even if they refer to the same document, the document might contain special getters and setters which overide those of window.document...
answered Jan 3 at 22:01
Nuno SousaNuno Sousa
21128
21128
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
I see what you're saying. Writing justdocument
doesn't access it through the Window object, so it doesn't use the getter/setter.
– Barmar
Jan 3 at 22:17
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
add a comment |
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
I see what you're saying. Writing justdocument
doesn't access it through the Window object, so it doesn't use the getter/setter.
– Barmar
Jan 3 at 22:17
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Getters and setters can't tell what expression was used to access them.
– Barmar
Jan 3 at 22:05
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
Yes, but windows getters and setters are run first before documents getters and setters, and they could potentially overide them. I can run you an example if you would like.
– Nuno Sousa
Jan 3 at 22:15
I see what you're saying. Writing just
document
doesn't access it through the Window object, so it doesn't use the getter/setter.– Barmar
Jan 3 at 22:17
I see what you're saying. Writing just
document
doesn't access it through the Window object, so it doesn't use the getter/setter.– Barmar
Jan 3 at 22:17
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
Yes, absolutely, it's just something that could happen, and which might explain the difference in output. I have absolutely no idea if it does. (probbly not)
– Nuno Sousa
Jan 3 at 22:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030211%2freally-window-document-and-document-inside-window-is-not-the-same-chrome%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
btgJp77okZ
Possible duplicate of What is the difference between window, screen, and document in Javascript?
– devlin carnate
Jan 3 at 21:46
1
No, it's a fully different question. @devlincarnate
– Max Travis
Jan 3 at 21:47
@devlincarnate this is a different question. Delete your duplication mark in my post! I'm not asking about dimensions of the DOM, instead I'm wonder about differents in document and window.document!
– Max Travis
Jan 3 at 21:51
I don't know the proper answer but I assume it is just a matter of interpretation. Chrome developers just assumed that in console, when you type
document
you want to see the DOM, whereas if you want all info you just typewindow.document
.– Oliver Tušla
Jan 3 at 21:54
@OliverTušla haha, just type the what you wrote above -
window.document
and you will be wonder by what you see in console.... You don't right– Max Travis
Jan 3 at 21:56