Willem van der Veen
Willem van der Veen

Reputation: 36620

Accessing the DOM via chrome console

Some questions regarding the DOM and what it exactly is.

When I access document via console.dir I get all the properties of document like this:

DOM javascript

When I do a console.log I get something which looks more like the DOM:

DOM javascript

Questions:

  1. In my understanding the second object which we get from console.log() is the DOM. and the one from console.dir() is the DOM and all the Javascript properties which exists on the DOM. Is this correct?
  2. Is the DOM is a Javascript object?
  3. Can we access the DOM structure of element nodes which we get from console.log(window.document) from a property of console.dir(window.document)?

Upvotes: 0

Views: 493

Answers (1)

SLaks
SLaks

Reputation: 887415

The DOM (Document Object Model) is a generic term for a set of objects.

document is a DOM object; you're just seeing two different ways of representing it.

You can access the DOM hierarchy via properties like .children.

For more information, see the documentation.

Upvotes: 1

Related Questions