var i = 0; var timer = setInterval(function() { i++ console.log(i); //alert(1); }, 2000); alert( typeof timer ); // number //注释: timer(); 计时器也会自动执行