Scroll to the bottom in JavaScript

To scroll to the bottom of the page in JavaScript:

javascript
window.scrollTo(0, document.body.scrollHeight)

With a smooth behavior:

javascript
window.scroll({top: document.body.scrollHeight, behavior: 'smooth'})

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.