js setTimeout如何调用自身所在的函数(有参数传递的)?

2025-05-11 08:19:27
推荐回答(2个)
回答(1):


function test(name,time){
alert(name);

setTimeout(function() { test(name,time); },time);//setTimeout();这里应该怎么写 ???
}

test("123", 1000);

 其实和setInterval这个函数的功能是一样的

回答(2):

setTimeout(function(e){
    if(e > 9) return;
    console.log(e);
    setTimeout(arguments.callee(e - 1),1500);
},1000);