What is Async JavaScript?




Learn about asynchronous behavior in JavaScript.

Learn about callbacks for async flow control:

and promises:

Code examples from this video: https://github.com/shama/letswritecode/tree/master/what-is-async-javascript

Original source


13 responses to “What is Async JavaScript?”

  1. Now on making your own custom asynchronous functions. You seem to have confirmed what I have found out there (amongst very poor explanations), that being you can't make your own. At best you can piggyback on one of the pre-existing specific javascript engine implementation extension functions. These actually run in a separate thread in the larger mechanism that hosts the JavaScript engine (like a browser or Node). Some of these extension functions take your custom callback function and place it on the event queue. Thus you are effectively hijacking one of these to get your code on the queue. I think this is what all the JS frameworks are really doing under the covers. Do I have this correct? Thanks again!

  2. First off I love the bear analogy!
    So, you seem to have confirmed what I originally suspected was going on. That is once an asynchronous code chuck starts to execute it will not get interrupted. If that code takes 30 minutes it will temporarily block everything for 30 continuous minutes. Effectively when you write asynchronous code you are merely allowing places in your code for things outside of your program to get a chance to execute. Everything I read says "when you have a long running function make it async so you don't block", but it sounds like it's going to block, you are just putting it into a queue for later. So really if you have a "long running function" does it really have benefits running async? At best you just delayed it? Seems to me async code funcs need to execute quick for them to make sense or have a benefit. Also from your reply you confirmed that no two async functions execute at the same time. Do I have this all correct?

  3. Great job finally heard something I've been searching for in your video (and I've watched and read a lot on this) and that is that the async functions get executed, paused and resumed (over and over until complete) to allow other code to share the thread, essentially time sharing it. Now what makes an async function able to do this as opposed to regular code? And besides the built in or third party functions that are already async enabled how can I make my custom function async compliant? If you can answer these questions I think it will really help me get my brain around this. Thank you!!!!!! Keep up the good work.

  4. Can you make another, simpler video on callbacks and promises? I tried to understand the ones you already did but got lost. I've tried watching them multiple times too :/ I understand if u can't, but I'd appreciate it! Maybe I should start at the beginning of your videos, perhaps that'll help.

Leave a Reply