function foo(){ setTimeout(() => { console.log(new Date() + '') foo() }, (Math.random() * 5 | 0) * 1000) } foo()