IS(文档)JavaScript中的对象



在此代码中:

document.getElementById()

document是具有属性和方法的对象吗?

如果是,getElementById()是此对象上的方法吗?

如果否,则考虑什么documentgetElementById

是的, document是一个对象。

typeof document; // "object"

getElementById是该对象上的属性。

在浏览器中,documentDocument的实例。 document instanceof Document => true

它代表整个HTML页面。documentwindow的属性。 window.document === document => true

因此它可以用作全局对象。

最新更新