Author: https://t.me/ahillary
Channel: https://t.me/semolina_code_python
Chat: https://t.me/python_with_ahillary
YouTube: https://www.youtube.com/@semolinacode
Coding training: https://t.me/how_to_code_web3
Prop trading: https://t.me/semolina_prop
Обработчики промисов .then
/.catch
/.finally
всегда асинхронны.
Даже когда промис сразу же выполнен, код в строках ниже .then
/.catch
/.finally
будет запущен до этих обработчиков.
let promise = Promise.resolve();
promise.then(() => console.log("промис выполнен"));
console.log("код выполнен"); // этот console.log показывается первым
Почему .then
срабатывает позже? Что происходит?