The result of someElement.getBoundingClientRect() returns a special object of type ClientRect (or DomRect apparently)
Let's not overcomplicate things!
function getBoundingClientRect(element) {
var rect = element.getBoundingClientRect();
return {
top: rect.top,
right: rect.right,
bottom: rect.bottom,
left: rect.left,
width: rect.width,
height: rect.height,
x: rect.x,
y: rect.y
};
}
const getBoundingClientRect = element => {
const {top, right, bottom, left, width, height, x, y} = element.getBoundingClientRect()
return {top, right, bottom, left, width, height, x, y}
}
console.log(
getBoundingClientRect( document.body )
)