4 ms·
Does this actually work, though? I would expect it to fail similarly as this fails (note, may hang your browser or a tab, depending on your browser): var foo
by _flux 6y ago
Does this actually work, though? I would expect it to fail similarly as this fails (note, may hang your browser or a tab, depending on your browser):
var foo = [0];
function setFoo() {
console.log("Callback");
foo[0] = 1;
}
setTimeout(setFoo, 100);
console.log("Waiting..");
while (!foo[0]);
console.log("Done.");
Edited the original message with reversed arguments to setTimeout; doesn't seem to affect the results though. Really need to love the complete lack of error messages though..
- kuschku 6y agoIt doesn't, as promise resolution and execution is scheduled as new tasks on the main thread, which are only ever run if the currently executing piece of code finishes. That's pretty much identical between IO, setTimeout/setInterval and requestAnimationFrame