我给出最后一题我的正确实现 function repeat(func, times, wait) { function set(f) { let timer let count = 1 let print = () => { timer = setTimeout(() => { func(f) if (count >= times) { clearTimeout(timer) return } print(f) count++ }, wait) } print() } return set } // 输入 let log = console.log const repeatFunc = repeat(log, 4, 3000); // 输出 // 会alert4次 helloworld, 每次间隔3秒 repeatFunc('hellworld'); repeatFunc('1111')
点赞 4

相关推荐

2025-12-31 13:35
门头沟学院 Java
淬月星辉:还有我看你11月不是有一篇帖子说入职大厂忙的在地铁上崩溃大哭吗?怎么现在又说轻松了?你是搬运别人的帖子吗
微软公司氛围 71人发布
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务