Remi
Remi

Reputation: 5367

Difference [brackets] and <shevrons> in a Javascript object

The methods .getElementsByClassName() and getElementById() both output a different kind of object. The method by classname outputs brackets [div.child] around it, and the id method shows the object using shevrons: <div id="parent">.

https://jsfiddle.net/Spindle/v1p9pqj0/1/

What is the difference between the two objects?

I'm looking for a way where I could test if the child node of a specific node is the same. However, I can't compare them because the object seems to be different somehow.

Upvotes: 1

Views: 29

Answers (1)

Ahmed Musallam
Ahmed Musallam

Reputation: 9753

getElementsByClassName() returns a collection of HTML elements while getElementById() returns a single element

Basically the [] denote a collection/array And the <> denote an element

Upvotes: 1

Related Questions