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]

I removed the string concatenating to an object by just writing: console.log(results) and now it works.

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