What is the DOM?

A representation of the html elements of a webpage as an object. It can also be likened to a bridge between the content and the browser. Also called the Document Object Model.

DOM Selectors

Document - accesses the DOM

Examples:

document.getElementsByTagName(/* Tag Goes Here */);
document.getElementsByClassName(/* Class Name Here */);

It’s important to note that the plural getElements will always return an array-like list, even if there is only one item that falls into its range.

Examples 2:

// Does not return an array
document.getElementById(/* ID Name here */);
// Can grab CSS items such as ids, classes, elements, etc. It will only return the *first* result.
document.querySelector();
// Returns a *Node List*
document.querySelectorAll();

HTML Collection vs Node List

While neither can use the full breadth of array methods, Node Lists can use .forEach