2017-06-04 38 views
-1

在此代碼:是(文檔)在JavaScript中的對象?

document.getElementById() 

document具有的屬性和方法的對象?

如果是,是getElementById()這個對象上的一個方法嗎?

如果否,請考慮documentgetElementById是什麼?

+3

你想確定什麼? – guest271314

+0

是:https://developer.mozilla.org/en-US/docs/Web/API/Document –

回答

0

是的,document是一個對象。

typeof document; // "object" 

getElementById是該物體的一個屬性。

+2

'getElementById'是'Document'原型的一種方法。 – Kaiido

+0

是的,它是通過原型鏈繼承的。 – Trott

+0

'!! document.getElementById' ==>'true' – Trott

0

在瀏覽器中,documentDocument的一個實例。 document instanceof Document =>true

它代表整個HTML頁面。 和documentwindow的財產。 window.document === document =>true

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

相關問題