思路就是递归调用
代码语言:javascript复制function myInterval(fun,time){
function inside(){
fun();
setTimeout(inside,time);
}
setTimeout(inside,time);
}
myInterval(fn,1000);
function fn(){
console.log('嘿嘿');
}
思路就是递归调用
代码语言:javascript复制function myInterval(fun,time){
function inside(){
fun();
setTimeout(inside,time);
}
setTimeout(inside,time);
}
myInterval(fn,1000);
function fn(){
console.log('嘿嘿');
}