0

when i return milli in "updateClock()" it executes every 1 millisecond like a charm. But when i return mill it executes way slower. (very slow it takes 5 seconds to get mill to 1000) Before telling me that it takes some milliseconds to process the function i have to tell you in my function when i return milli i also do an ADDITIONAL but useless process "mill=mill+1" but it still "EXECUTES" every 1 millisecond.

const timer=document.getElementById('timer');
let mill=0;
let interval;

function int(){
    interval=setInterval(async() => {
        timer.innerText=updateClock();
    }, 1);
}

function updateClock() {
    var now = new Date();
    var milli = now.getMilliseconds()
    mill=mill+1
    return milli  //return mill
}

int();

0 Answers0