1. 程式人生 > >JasonHsu Blog_前端開發部落格,專注前端開發

JasonHsu Blog_前端開發部落格,專注前端開發

function clock() {
console.clear();

now = new Date();
h = now.getHours();
m = now.getMinutes();
s = now.getSeconds();
console.log(h + ":", m  + ":", s);
}
//每到一秒時,清空console,並顯示當前時間。
//console.clear()一定要在進入clock函式時執行。這樣才能保證時間持續顯示。
var now = setInterval(clock,1000);