Correction :
- a nodeList is returned when you call a function which may select more than 1 element
- a HTMLElement is returned when you call a function which can select 1 element at most
This way you don't have to test the type of the returned value at each call.
querySelectorAll
is designed to return an undefined number of elements, so it returns a nodeList
.
On the contrary there's generally no point in returning a nodeList when you use getElementById
(as one element at most may have a given id), that's why it directly returns one element (or null).