How to check Scrollbar is reached to the bottom

function IsScrollbarAtBottom(VARIABLE) {

var totalheight = 1;

var inteoffheight =0;

while(totalheight >inteoffheight){

var scrollheight= _eval("document.getElementsByClassName('k-scrollbar k-scrollbar-vertical')[2].scrollHeight");

var intescrollheight =parseInt(scrollheight);
log(intescrollheight);

var scrolly = _eval("document.getElementsByClassName('k-scrollbar k-scrollbar-vertical')[2].scrollTop");
var intescrolly = parseInt(scrolly);
log(intescrolly);
var offheight = _eval("document.getElementsByClassName('k-scrollbar k-scrollbar-vertical')[2].clientHeight");
inteoffheight = parseInt(offheight);
log(inteoffheight);

totalheight= intescrollheight - intescrolly
log(totalheight);

 if (isVisible(cell((VARIABLE)))){

totalheight = inteoffheight;

 }
else
  {
     _eval("document.getElementsByClassName('k-scrollbar k-scrollbar-vertical')[2].scroll(0,40000)");
    
  }

}
}
IsScrollbarAtBottom(VARIABLE);