JavaScript uses objects and methods to display output on a webpage. One of the most commonly used objects is document. The document object uses the write method to create new content on a webpage. Method is also known as a member of the document object. To access the write method, we use a dot to link the document object with its write method, as follows:
document.write(‘text’);
Besides methods, the document object also has properties. One of the properties is bgcolor that determines the background colour of a webpage. The syntax to access the properties is the same as the syntax to access the method.
For example,
document.bgColor = “cyan”;
produces a webpage with cyan background.