JSFiddle - React, Tailwind, and code Playground
JavaScript
'use strict';
function getUser (id, resolve) {
setTimeout(() => {
resolve({
id: id
});
}, Math.random() * 1000);
}
// Notice that user.id is printed not in the order that getUser function is called.
for (let id = 10; id--;) {
getUser(id, (user) => {
console.log('user.id', user.id);
});
}