Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Wrong behavior of nested setTimeout #8133

Closed
loyd opened this issue Aug 11, 2014 · 1 comment
Closed

Wrong behavior of nested setTimeout #8133

loyd opened this issue Aug 11, 2014 · 1 comment

Comments

@loyd
Copy link

loyd commented Aug 11, 2014

function work(ms) {
  var start = Date.now();
  while (Date.now() - start < ms);
}

function test() {
  var st = Date.now();
  setTimeout(function() {
    work(60); // must be greater then the delay
    setTimeout(function() {
      console.log(Date.now()-st);
    }, 50);
  }, 50);
}

Result (node): 220
Result (chrome): 160

@loyd loyd mentioned this issue Aug 11, 2014
@trevnorris
Copy link

Dup of #8105.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants