getElementsByClassName
returns HTMLCollection in modern browsers.
which is
array-like object similar to arguments which is iteratable by for...of
loop see below what MDN doc is saying about it:
The for...of statement creates a loop iterating over iterable objects, including: built-in String, Array, Array-like objects (e.g., arguments or NodeList), TypedArray, Map, Set, and user-defined iterables. It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object.
example
for (const element of document.getElementsByClassName("classname")){
element.style.display="none";
}