JSFiddle - React, Tailwind, and code Playground

HTML

<div style="">
  <div id="z">
    <span id="txt">
     345345345345345345345345345345345
    </span>
  </div>
</div>

CSS

div#z {
  position: relative;
  background: red;
  width: 50px;
  height: 50px;
  overflow: auto;
}

div#txt {
  background: lightblue;
  float: right;
}

JavaScript

alert(JSON.stringify(checkOverflow(document.getElementById('z')))) ;

function checkOverflow(el) {

  var curOverflow = el.style.overflow;

  

  var isOverflowing = el.clientWidth < el.scrollWidth;

  return {a:isOverflowing, b:el.offsetWidth, c:el.scrollWidth} ;
};