tezvyn:

The `document` Object: Your Page's API

Source: developer.mozilla.orgbeginner

The `document` object is the root of the DOM tree, representing the entire webpage in your script. Use it to find elements (`getElementById`), create new ones (`createElement`), or read page info. The main footgun: accessing an element before it's been parsed.

The `document` object is the API for the webpage, serving as the entry point to the DOM tree. It represents the entire page, allowing you to access and manipulate all its content. You'll use it constantly to find elements (`querySelector`), create new ones (`createElement`), and read page properties. The most common footgun is running a script that tries to access an element before the browser has parsed it, resulting in `null`. This often happens with scripts placed in the `<head>` trying to access the `<body>`.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

The `document` Object: Your Page's API · Tezvyn