what wrong on scroll top functionality

Is this correct way to add scroll top functionality?

function toTop(){
  const topTrigger = document.querySelector('.back-to-top');

  topTrigger.addEventListener('click', () => {
    window.scrollTo({
      top: 0,
      left: 0,
      behavior: 'smooth',
    });
  });
}
toTop();