This is the perfect use case for .setInterval()(Scroll down to the setIntervall() part below setTimeout())
var myVar = setInterval(myTimer, 1000);
function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
console.log(t);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…