I am executing simple javascript function with setInterval which just print date & time
console.log('before',new Date().toLocaleString(), new Date().getMilliseconds())
setInterval(() => {
console.log(new Date().toLocaleString(), new Date().getMilliseconds());
}, 1000);
output of code is
before 7/27/2023, 9:06:14 PM 364
7/27/2023, 9:06:15 PM 367
7/27/2023, 9:06:16 PM 370
7/27/2023, 9:06:17 PM 372
7/27/2023, 9:06:18 PM 376
7/27/2023, 9:06:19 PM 378
7/27/2023, 9:06:20 PM 382
my question is why does it always add some milliseconds on every execution of code, okay I know that it take some jitter milliseconds to actually add function to call stack then it should not always add jitter milliseconds to the previous function call.
why output would not look like this ?
before 7/27/2023, 9:06:14 PM 364
7/27/2023, 9:06:15 PM 367
7/27/2023, 9:06:16 PM 367
7/27/2023, 9:06:17 PM 367
7/27/2023, 9:06:18 PM 368
7/27/2023, 9:06:19 PM 367
7/27/2023, 9:06:20 PM 367