Noob question about runtime and DOM stuff #597
-
When running |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
document is a property of host object window which is a global object of a browser. The So if you try to access I hope this answers your question! |
Beta Was this translation helpful? Give feedback.
-
Closing as answered/settled. |
Beta Was this translation helpful? Give feedback.
document is a property of host object window which is a global object of a browser. The
document
object refers to the HTMLdocument object of the currently opened html file. And as HTML has a structure ofhead
andbody
, you can accessbody
element as a property ofdocument
object and this is just how the object is implemented by specification. (correct me if I am wrong). Thedocument
do hold the HTMLElement you appended to the body, but not a direct reference to it. You might want to open a consoleF12
and type in document and expand on it to see the properties.So if you try to access
bar
fromdocument
, it is not there since it is not a property of thedocument
object.If you create an el…