使用setInterval模拟setTimeout:

 

执行一次setInterval然后清除即可

function mySetTimeout(fn, t){
    let timer = setInterval(()=>{
        fn();
        clearInterval(timer)
    },t)
}

let a = mySetTimeout(()=>{
    console.log('xxx')
},1000)