getElementsByClassName() and getElementsByTagName() are both return live HTMLCollection of…
Konstantin Rouda

I corrected the function name by appending “All” to its end. Your comment and Bob’s has inspired me to improve the copy. Thank you.

The basic idea was to give the programmer the choice to use any of these three functions, that can be used together with Object.entries to output the list of selected elements:

let div1 = document.getElementsByClassName("image");
let div2 = document.getElementsByTagName("div");
let div3 = document.querySelectorAll("div");
Object.entries(div1).map(( object ) => { console.log( object ) });
Object.entries(div2).map(( object ) => { console.log( object ) });
Object.entries(div3).map(( object ) => { console.log( object ) });

As a JavaScript programmer for many years I still struggle with remembering all the possible function names, objects they return and so forth.

It’s so basic (but nonetheless, a useful example) that I failed to edit as I was writing it. I’m thankful for this iterative content improvement (over a period of time) idea that I learned from other software engineers.

Like what you read? Give JavaScript Teacher a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.