function delay(a) {
setTimeout(() => {
console.log(a);
}, 1000);
}
function prompt(a) {
console.log(a);
}
var temp = function() {
return new Promise((resolve) => {
delay('first');
resolve();
});
};
temp().then(() => {
prompt('second');
});
I want to print it out in the order of first and second.
The output starts from the second.
Can we print it out in first second order without modifying the delay() and promt() functions?
function delay(a, resolve) {
setTimeout(() => {
console.log(a);
resolve();
}, 1000);
}
function prompt(a) {
console.log(a);
}
var temp = function() {
return new Promise((resolve) => {
delay('first', resolve);
});
};
temp().then(() => {
prompt('second');
});
3078 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
1751 I want to run pyautogui without remote connection on Windows 10 in the cloud
1946 I want to connect to the webcam from WSL(ubuntu)
1787 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2026 OneMinuteCode. All rights reserved.