Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) The Browser Environment The Browser Environment Review

Kevin Ohlsson
Kevin Ohlsson
4,547 Points

DOM & Document not the same?


In the review section the following question is asked

Quiz Question 3 of 5
The ___ is a representation of the document that JavaScript uses to navigate and make changes to a webpage.

the correct answer is DOM (Document Object Model)

I am confused. It seems to me as if the question is hinting that the DOM is a representation of the document.

Is the DOM and the document not the same thing?

1 Answer

Balazs Peak
Balazs Peak
46,089 Points

The DOM is the correct answer.

The DOM and the document are not the same thing programatically, but you can think of it like that. Just keep in mind that the document which is downloaded to the client, and showed in the browser, is represented in the JavaScript code by the DOM - hence the name, Document Object Model.

JavaScript is a programming language, those usually treat different pieces of data and resources as variables or objects. The JavaScript compiler needs an object which represents the document, in order to work with it. It can not access the document directly, there has to be a way, a pipeline, an API, whatever you want to call it.