cómo detener el temporizador con otra función javascript

Entonces tengo este código

function timer()
{
     setTimeout(function(){alert("Out of time")}, 3000); //Alerts "Out of time" after 3000 milliseconds
}
function resetTime()
{
     timer(); //this is not right, i thought it would override the first function but it just adds another timer as well which is not what I want
}
function stopTime()
{
     //What could go here to stop the first function from fully executing before it hits 3000 milliseconds and displays the alert message?
}

el temporizador de funciones () comienza cuando se carga la página, pero si tengo un botón para stopTime () y hago clic en él, ¿cómo detengo la ejecución de la primera función y evito que llegue a la marca de 3000 milisegundos y alerta "Fuera de tiempo "?

Respuestas a la pregunta(3)

Su respuesta a la pregunta