js自定制周期函数

function mySetInterval(fn, milliSec,count){
        function interval(){
            if(typeof count==='undefined'||count-->0){
                setTimeout(interval, milliSec);
                try{
                    fn()
                }catch(e){
                    t = 0;
                    throw e.toString();
                }
            }
        }
        setTimeout(interval, milliSec)
    }
原文地址:https://www.cnblogs.com/lizhang4/p/9049566.html