How to stop audio in JavaScript

DOM
By Jad Joubran · 
Last updated Feb 26, 2024
<audio>
  <source src="audio.mp3" type="audio/mpeg" />
</audio>
const audio = document.querySelector("audio");

// Stop = pause + reset the playhead
audio.pause();
audio.currentTime = 0;