getBoundingClientRect() Doesn't Return Information About the Box

In my HTML:

<div id="box">Some text</div>

In my CSS:

#box {width:222px; height:111px;}

In my JavaScript:

const section2 = document.getElementById('box');
const results = section2.getBoundingClientRect();
console.log("results " + results);

console.log returns:
results [object DOMRect]

I expected an object providing information about the size of the element and its position relative to the viewport but I simply got [object DOMRect]

You are concatenating the object to a string. Try console.log(results);

That worked! Thank you, nibble

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.