贴个setTimeout的

function count(start, end) {
    for(let i=start;i<=end;++i)
        st=setTimeout(() => {console.log(i)},(i-2)*1000);

    return{
         cancel:function(){
            clearTimeout(st);
        }
    }    
}