Why return Doesn’t Work in setTimeout: The JavaScript Async Model Explained

📰 Medium · JavaScript

(And What You Should Do Instead) Continue reading on Medium »

Published 14 Apr 2026

Full Article

Title: Why return Doesn’t Work in setTimeout: The JavaScript Async Model Explained

URL Source: https://medium.com/@akanksha.mohanty.sg/why-return-doesnt-work-in-settimeout-the-javascript-async-model-explained-080c26b56639?source=rss------javascript-5

Published Time: 2026-04-14T17:03:59Z

Markdown Content:
# Why return Doesn’t Work in setTimeout: The JavaScript Async Model Explained | by Akanksha Mohanty | Apr, 2026 | Medium

[Sitemap](https://medium.com/sitemap/sitemap.xml)

[Open in app](https://play.google.com/store/apps/details?id=com.medium.reader&referrer=utm_source%3DmobileNavBar&source=post_page---top_nav_layout_nav-----------------------------------------)

Sign up

[Sign in](https://medium.com/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2F%40akanksha.mohanty.sg%2Fwhy-return-doesnt-work-in-settimeout-the-javascript-async-model-explained-080c26b56639&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)

[](https://medium.com/?source=post_page---top_nav_layout_nav-----------------------------------------)

Get app

[Write](https://medium.com/m/signin?operation=register&redirect=https%3A%2F%2Fmedium.com%2Fnew-story&source=---top_nav_layout_nav-----------------------new_post_topnav------------------)

[Search](https://medium.com/search?source=post_page---top_nav_layout_nav-----------------------------------------)

Sign up

[Sign in](https://medium.com/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2F%40akanksha.mohanty.sg%2Fwhy-return-doesnt-work-in-settimeout-the-javascript-async-model-explained-080c26b56639&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)

![Image 1](https://miro.medium.com/v2/resize:fill:32:32/1*dmbNkD5D-u45r44go_cf0g.png)

# Why `return` Doesn’t Work in `setTimeout`: The JavaScript Async Model Explained

[![Image 2: Akanksha Mohanty](https://miro.medium.com/v2/resize:fill:32:32/0*w11XXuKk20k6lKFD.jpg)](https://medium.com/@akanksha.mohanty.sg?source=post_page---byline--080c26b56639---------------------------------------)

[Akanksha Mohanty](https://medium.com/@akanksha.mohanty.sg?source=post_page---byline--080c26b56639---------------------------------------)

Follow

3 min read

·

1 hour ago

[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Fp%2F080c26b56639&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40akanksha.mohanty.sg%2Fwhy-return-doesnt-work-in-settimeout-the-javascript-async-model-explained-080c26b56639&user=Akanksha+Mohanty&userId=2de3deccf6de&source=---header_actions--080c26b56639---------------------clap_footer------------------)

1

[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2F080c26b56639&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40akanksha.mohanty.sg%2Fwhy-return-doesnt-work-in-settimeout-the-javascript-async-model-explained-080c26b56639&source=---header_actions--080c26b56639---------------------bookmark_footer------------------)

[Listen](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2Fplans%3Fdimension%3Dpost_audio_button%26postId%3D080c26b56639&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40akanksha.mohanty.sg%2Fwhy-return-doesnt-work-in-settimeout-the-javascript-async-model-explained-080c26b56639&source=---header_actions--080c26b56639---------------------post_audio_button------------------)

Share

(And What You Should Do Instead)

Press enter or click to view image in full size

![Image 3](https://miro.medium.com/v2/resize:fit:700/1*5Uvd_uHGWxpS35yarv0Agg.png)

The `setTimeout` Trap That Confuses Every JavaScript Developer

If you’ve ever written JavaScript like this:

function asyncFn(msg) {

setTimeout(() => {

return `Subscribe to ${msg}`;

}, 1000);

}

const result = asyncFn("YouTube");

console.log(result);
…and stared in disbelief at:

undefined
You’re not alone.

This confusion is **one of the most common JavaScript pitfalls**, especially for de
Read full article → ← Back to Reads