Asynchronous JavaScript

Asynchronous JavaScript

What is Asynchronous about JavaScript?
Includes code Examples and explains why it is better. Part of http://nodegirls.io/ presentation "What is Node.js"

5c993eb3c38f0b81891fa947adfeb95a?s=128

Natalia Baltazar

July 02, 2016
Tweet

Transcript

  1. Asynchronous JavaScript

  2. What is asynchronous JavaScript ? JS is actually single threaded

    and is mostly synchronous Async things are: • AJAX calls • Events
  3. None
  4. Asynchronous Synchronous 2 waiting 1 3 4 2 waiting 1

    3 4
  5. /******************************************************************************************** For example, if you go down to a fast

    food joint and order a cheeseburger they will immediately take your order and then make you wait around until the cheeseburger is ready. In the meantime they can take other orders and start cooking cheeseburgers for other people. Imagine if you had to wait at the register for your cheeseburger, blocking all other people in line from ordering while they cooked your burger! This is called blocking I/O because all I/O (cooking cheeseburgers) happens one at a time. Node, on the other hand, is non-blocking, which means it can cook many cheeseburgers at once. ********************************************************************************************/ https://github.com/maxogden/art-of-node
  6. None
  7. So… How do you make the code behave?

  8. Callbacks

  9. None
  10. None
  11. Any Questions?