setInterval 调用

 function direct() {
        console.info( "time: ", ( new Date() ).getTime() );
    }
    function showlog() {
        setInterval(direct(), 1000);
    }
    function showlog_2() {
        setInterval( direct, 1000 );
    }
    function showlog_3() {
        setInterval( function () {
            direct();
        }, 1000 );
    }
    function showlog_4() {
        setInterval( "direct()", 1000 );
    }
    // showlog(); //=> 执行一次
    // showlog_2(); //=> 每隔 1000毫秒 执行一次
    // showlog_3(); //=> 每隔 1000毫秒 执行一次
    // showlog_4(); //=> 每隔 1000毫秒 执行一次

 

posted @ 2017-12-14 17:42  DR19  阅读(116)  评论(0)    收藏  举报