const audioElement = new Audio("car_horn.wav");HTMLAudioElement / notebook
HTMLAudioElement
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
audioElement.play();const audioElement = new Audio("car_horn.wav");
audioElement.addEventListener("loadeddata", () => {
let duration = audioElement.duration;
// The duration variable now holds the duration (in seconds) of the audio clip
});