var timer = null; function ttt(param){ alert(timer); if(!timer){ timer = setTimeout(function(){alert(timer)},150); } else{ clearInterval(timer); timer = null; } } ttt();