(文档)是javascript中的对象吗?
在此代码中:(文档)是javascript中的对象吗?,javascript,dom,Javascript,Dom,在此代码中: document.getElementById() document是一个具有属性和方法的对象吗 如果是,则getElementById()是否是此对象上的方法 如果否,则考虑的文档和getElementById是什么?是,文档是一个对象 typeof document; // "object" 而getElementById是该对象的属性。在浏览器中,document是document的实例。 document instanceof document=>true 它代表整个H
document.getElementById()
document
是一个具有属性和方法的对象吗
如果是,则getElementById()
是否是此对象上的方法
如果否,则考虑的
文档
和getElementById
是什么?是,文档
是一个对象
typeof document; // "object"
而
getElementById
是该对象的属性。在浏览器中,document
是document
的实例。
document instanceof document
=>true
它代表整个HTML页面。
而文档
是窗口
的一个属性。
window.document===document
=>true
因此它可以用作全局对象。
getElementById
是文档
原型的一种方法。是的,它是通过原型链继承的。!!document.getElementById
==>true
@kaido'getElementById'在document===true
中该函数仍然可以从document
访问,尽管它不是直接所有者。@guest271314document
通过[currentDocumentType]document
proto继承自document
文档。因此,根据OP的期望,它可能会有所不同。您想确定什么?是的: