0% found this document useful (0 votes)
61 views

Asynchronous Javascript: Evozon Techtalk #3

This document discusses asynchronous JavaScript. It explains that asynchronous code schedules operations to occur in the future rather than executing statements sequentially like synchronous code. Common ways to achieve asynchronicity include callbacks, promises, generators, and async/await. Callbacks can lead to "callback hell" while promises can be chained and async/await uses try/catch to handle errors across synchronous and asynchronous code.

Uploaded by

Sergiu Pop
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Asynchronous Javascript: Evozon Techtalk #3

This document discusses asynchronous JavaScript. It explains that asynchronous code schedules operations to occur in the future rather than executing statements sequentially like synchronous code. Common ways to achieve asynchronicity include callbacks, promises, generators, and async/await. Callbacks can lead to "callback hell" while promises can be chained and async/await uses try/catch to handle errors across synchronous and asynchronous code.

Uploaded by

Sergiu Pop
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Asynchronous Javascript

Evozon TechTalk #3
Synchronous code

• Statements executed one after another

• Problem! Execution might be blocked..


Asynchronous code

• Statements schedules something to happen in the future


• Asynchronous != Concurrent/Multi-threaded
How to achieve asynchronicity?

• Treat functions as first class functions/objects:


• Store in variable
• Pass to/Return from another function
Callbacks

• Function passed to another function as a parameter


• E.g. setTimeout, on (jQuery)

• Problem!
• Callback hell
• No ‘throw’ keyword
• Can’t return values
Promises

• Object producing a single value some time in the future


• Use callbacks
• Can be chained
Generators – “Run..Stop..Run”

• Follows Iterator interface


• Pause a function execution -> do other things -> return to function
• yield – pass control to external system
Async/Await

• Still uses promises


• Uses try/catch to handle both sync/async errors

You might also like