The method $\texttt{querySelector}$ is the single-result CSS lookup. Its argument is any CSS selector, and a leading dot means match by class.
If the page has many elements with that class, $\texttt{querySelector}$ still hands back just one, the first it meets while scanning the document. For the full set you need the sibling method $\texttt{querySelectorAll}$.
It does not raise an error on duplicates and does not care about IDs, so the correct behavior is returning the first matching element.
\[\boxed{\text{Selects the first element with the given class name}}\]