function wait(seconds) {   return new Promise(resolve => {     setTimeout(resolve, seconds);   }); } function repeat(func, times, s) {   return async function (...args) {     for (let i = 0; i < times; i++) {       func.apply(null, args);       await wait(s);     }   }; } const repeatFunc = repeat(alert, 4, 2000); repeatFunc("hellworld");//会alert4次 helloworld,每次间隔3秒
点赞 1

相关推荐

哞客37422655...:高端人士品鉴简历给到顶级,先投递试试。别着急给自己转测开的评价
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务