📅  最后修改于: 2022-03-11 15:03:16.928000             🧑  作者: Mango
function recursiveSetTimeout(iterations) {
return new Promise((resolve, reject) => {
function repeat(count) {
if (!count) return resolve("finished")
console.log(count)
setTimeout(repeat.bind(null, count-1), 300)
}
repeat(iterations)
})
}
recursiveSetTimeout(3).then((result)=>{console.log(result)})