Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task queue is not extrictly FIFO. #33

Open
hrivera2014 opened this issue May 15, 2022 · 1 comment
Open

Task queue is not extrictly FIFO. #33

hrivera2014 opened this issue May 15, 2022 · 1 comment

Comments

@hrivera2014
Copy link

hrivera2014 commented May 15, 2022

Task queue is not extrictly FIFO, as this code demonstrate.

const promise1 = new Promise((resolve, reject) => {
  setTimeout(resolve, 3000, 'one');
});

const promise2 = new Promise((resolve, reject) => {
  setTimeout(resolve, 0, 'two');
});

Promise.race([promise1, promise2]).then(function race(value) {
  console.log(value);
  // Both resolve, but promise2 is faster
});
// expected output: "two"

@Vaibhavatchicmic
Copy link

yes it is

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

No branches or pull requests

2 participants