Understand three concepts
a.scrollTop ----> the distance above the a box is rolled
a.scrollHeight ----> the true height of a box, including hidden
a.offsetHeight —> the visual height of a box,
Then, when the rolled height is equal to the real height-the visible height, that is, when the hidden height you can't see in the picture above is equal to the height of the box being rolled, it reaches the bottom.
So if (a.scrollTop === a.scrollHeight-a.offsetHeight ){ console.log('to the bottom')}