3 ms·
I opened Node.js and did setInterval(() => console.log(Date.now()), 1); to watch the transition. Happy 1.7B seconds since Jan 1 1970!
by xeckr 3y ago
I opened Node.js and did
setInterval(() => console.log(Date.now()), 1);
to watch the transition. Happy 1.7B seconds since Jan 1 1970!
- jackconsidine 3y agoWe had our game of code-names self destruct at the exact moment using very similar code. Good times
- benatkin 3y agohmm, it didn't occur to me to use a timer rather than hit the up arrow and enter. Now I have this to watch the time count up :) async function* seconds() { while (true) { const millis = new Date().valueOf() const seconds = Math.ceil((millis + 10) / 1000) const delay = (seconds * 1000) - millis await new Promise(r => { setTimeout(() => r(), delay) }) yield seconds } } for await (const s of seconds()) { console.log(s) }
- xeckr 3y ago>async generator >for await (const s of seconds()) I'd hate to be your code reviewer!
- ftmch 3y agoFun fact: setInterval() might not be the most accurate timer, as it might drift after a while.