Asynchronous JavaScript in ~10 Minutes - Callbacks, Promises, and Async/Await

James Q Quick
8 Dec 202013:55

Summary

TLDRIn this video, JamesQuick dives into the intricacies of asynchronous JavaScript, a fundamental yet challenging aspect of the language. He breaks down the concept into three main categories: callbacks, promises, and async/await. Starting with the basics of callbacks and their potential pitfalls, such as 'callback hell', he then introduces promises as an improvement over callbacks, demonstrating how they handle success and error cases. Finally, he presents async/await as the preferred method for writing asynchronous code, showcasing its readability and ease of use with examples like reading files and making API requests. The video aims to clarify these concepts, making them accessible for web developers looking to master asynchronous JavaScript.

Takeaways

  • 😀 Asynchronous JavaScript is a fundamental concept in JavaScript that makes the language unique and is essential for day-to-day coding.
  • 🔄 There are three main categories of asynchronous JavaScript: callbacks, promises, and async/await, each with its own approach to handling asynchronous operations.
  • ⏱ Callbacks are functions passed into other functions to be executed later, often used in scenarios like `setTimeout` and event listeners, but can lead to 'callback hell' with nested functions.
  • 📚 Error-first callbacks are a pattern where the first parameter of a callback function is reserved for an error object, allowing error handling within asynchronous operations.
  • 🔄 Promises are an improvement over callbacks, providing a more manageable way to handle asynchronous operations with `.then()` for success and `.catch()` for errors.
  • 🔄 `fs.promises` in Node.js and the Fetch API are examples of built-in modules that use promises to simplify file operations and HTTP requests respectively.
  • 🆕 Async/await is a newer feature that simplifies writing asynchronous code by allowing the use of `await` to wait for a promise's resolution within an `async` function.
  • 👍 Async/await is the preferred method for the script's author due to its readability and ease of handling errors with try/catch blocks.
  • 🛑 Unhandled promise rejections can occur if the error case is not properly caught, highlighting the importance of comprehensive error handling in asynchronous code.
  • 📚 The script provides practical examples of asynchronous JavaScript, including reading files, handling HTTP requests with the Fetch API, and dealing with errors.
  • 🔧 Converting older callback-based code to promises and then to async/await is a way to modernize and improve the structure and readability of JavaScript code.

Q & A

  • What are the three main categories of asynchronous JavaScript discussed in the video?

    -The three main categories of asynchronous JavaScript discussed in the video are callbacks, promises, and async/await.

  • Why is asynchronous JavaScript considered an important concept to learn?

    -Asynchronous JavaScript is important because it is core to how JavaScript works, especially in day-to-day coding, and it makes JavaScript unique compared to other languages.

  • What is a callback and how is it used in JavaScript?

    -A callback is a function passed into another function to be executed later. In JavaScript, callbacks are used in scenarios like setTimeout, where the callback function is executed after a specified delay.

  • Can you explain the concept of 'callback hell' mentioned in the video?

    -Callback hell refers to the situation where multiple callbacks are nested within each other, leading to complex and hard-to-maintain code structures that resemble a 'Christmas tree' pattern.

  • How does the video demonstrate the use of callbacks with events in JavaScript?

    -The video demonstrates the use of callbacks with events by showing an example of using `button.addEventListener` to listen for a click event and execute a callback function when the event occurs.

  • What is an 'error-first callback' and why is it significant?

    -An 'error-first callback' is a callback pattern where the first parameter is reserved for an error object. It is significant because it allows developers to handle errors in asynchronous operations more effectively.

  • How does the video explain the evolution from callbacks to promises?

    -The video explains that promises evolved from callbacks to provide a cleaner and more manageable way to handle asynchronous operations. Promises use the `resolve` and `reject` functions to handle success and failure paths, respectively.

  • What is the main advantage of using promises over callbacks in JavaScript?

    -The main advantage of using promises over callbacks is that promises allow for better error handling with `.catch()` and make the code more readable and maintainable by avoiding deeply nested callback structures.

  • How does the 'async/await' syntax simplify writing asynchronous code in JavaScript?

    -The 'async/await' syntax simplifies asynchronous code by allowing developers to write code that looks and behaves more like synchronous code. It uses the `await` keyword to pause the execution of an async function until the promise is resolved or rejected.

  • What is the purpose of the 'try/catch' block when using async/await?

    -The 'try/catch' block is used with async/await to handle any errors that occur during the execution of the asynchronous operations. It allows for error handling similar to synchronous code.

  • Can you provide an example of how the video uses async/await with the fetch API?

    -The video demonstrates using async/await with the fetch API by defining an async function that awaits the fetch request, awaits the JSON response, and then processes the data. If an error occurs, it is caught and handled in a try/catch block.

Outlines

00:00

😖 Understanding Callbacks in Asynchronous JavaScript

Jamesquick introduces the complexities of asynchronous JavaScript, focusing on callbacks as the first category. He explains that callbacks can lead to 'callback hell' due to nested functions, which can complicate code structure. He also discusses the importance of error handling in callbacks, using 'fs.readFile' as an example to demonstrate error-first callbacks, where the first parameter in the callback function is reserved for error reporting.

05:00

🚀 Promises: The Evolution from Callbacks

The script moves on to promises, which are presented as an advancement over callbacks. Promises are objects representing the eventual completion or failure of an asynchronous operation. The video explains how to create and use promises, including the use of 'resolve' and 'reject' to handle outcomes. It also covers the use of '.then' for successful outcomes and '.catch' for errors, providing examples with 'fs.promises.readFile' and the fetch API, illustrating a cleaner and more manageable way to handle asynchronous operations compared to callbacks.

10:01

🔥 Embracing Async/Await for Cleaner Async Code

The final part of the script introduces async/await, which is portrayed as the preferred method for writing asynchronous JavaScript by the presenter. Async/await simplifies the code by allowing the use of 'await' within an 'async' function to pause the execution until the promise is resolved, after which the subsequent code can use the result directly. The video demonstrates how to use async/await with 'fs.promises.readFile' and the fetch API, also highlighting the use of try/catch blocks for error handling. This method is praised for its readability and is the presenter's recommended approach for modern JavaScript development.

Mindmap

Keywords

💡Asynchronous JavaScript

Asynchronous JavaScript refers to the ability of JavaScript to handle tasks without blocking the execution of other code. It is a core concept in the language that allows for non-blocking operations, such as handling user interactions, making network requests, or reading files. In the video, the theme revolves around understanding and implementing asynchronous behavior in JavaScript, with examples like `setTimeout` and file reading operations.

💡Callbacks

Callbacks are functions passed into other functions as arguments, which are then invoked inside the outer function to complete some kind of routine or action. In the context of the video, callbacks are used to handle asynchronous operations, such as the completion of a `setTimeout`. However, they can lead to 'callback hell', a term used to describe the complex and nested structure that can arise from using too many callbacks.

💡Promises

Promises in JavaScript are objects that represent the eventual completion or failure of an asynchronous operation. The video explains that promises are an evolution from callbacks, providing a cleaner way to handle asynchronous code with `.then()` for success and `.catch()` for error handling. An example from the script is using `fs.promises.readFile` to read a file asynchronously.

💡Async/Await

Async/await is a newer feature in JavaScript that simplifies writing asynchronous code. It allows the use of `await` within an `async` function to pause the execution until the promise is resolved or rejected. The video demonstrates how async/await can be used to streamline the process of making network requests with the Fetch API or reading files, making the code more readable and easier to maintain.

💡Error-first Callback

An error-first callback is a convention in Node.js where the first argument to the callback is reserved for an error object. If the operation is successful, the error object is `null` or `undefined`. The video illustrates this by showing how to read a file with `fs.readFile`, where the callback receives an error as the first parameter, followed by the data.

💡Node.js

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine, allowing JavaScript to be run on the server side. The video mentions Node when discussing file system operations and making HTTP requests, indicating that the examples are being run in a Node.js environment, which extends JavaScript's capabilities beyond the browser.

💡Fetch API

The Fetch API is a modern interface for making HTTP requests in JavaScript, replacing the older `XMLHttpRequest`. In the video, the Fetch API is used to make requests to the Pokemon API, demonstrating how promises can be chained to handle the asynchronous nature of network requests.

💡Unhandled Promise Rejection

An unhandled promise rejection occurs when a promise is rejected but there is no `.catch()` handler to deal with the error. The video script mentions this as a potential issue when using promises, highlighting the importance of error handling in asynchronous code.

💡Try/Catch

Try/catch is a statement used for error handling in JavaScript. The `try` block contains code that might throw an error, while the `catch` block catches and handles the error. In the video, try/catch is used with async/await to handle errors that might occur during asynchronous operations, such as making a fetch request or reading a file.

💡JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. In the context of the video, JSON is used when fetching data from an API, where the response is converted from JSON format into a JavaScript object for further processing.

💡Event Listener

An event listener is a function that is executed in response to an event, such as a user clicking a button. The video script mentions `addEventListener` in the context of JavaScript in the browser, where a callback function is provided to handle the event, demonstrating the use of callbacks in event handling.

Highlights

Introduction to the concept of asynchronous JavaScript and its importance in web development.

Explanation of JavaScript's asynchronous nature and its uniqueness compared to other programming languages.

Overview of the three main categories of asynchronous JavaScript: callbacks, promises, and async/await.

Introduction to the callback concept with an example of using setTimeout.

Demonstration of 'callback hell' with nested setTimeout functions.

Example of event listeners as a common use of callbacks in JavaScript.

Introduction to error-first callbacks and handling errors in asynchronous operations.

Explanation of promises as an evolution from callbacks, with resolve and reject mechanisms.

Demonstration of creating and using promises with fs module for file operations.

Introduction to the fetch API and its use with promises for making HTTP requests.

Explanation of async/await as the latest feature for writing asynchronous JavaScript.

Conversion of callback-based code to promises for better error handling and readability.

Use of async/await for simplified error handling with try/catch blocks.

Application of async/await in fetching data from the Pokemon API.

Personal preference for async/await over callbacks and promises for readability and ease of use.

Invitation for viewers to share their preferred method of handling asynchronous JavaScript.

Conclusion and anticipation for the next video on web development topics.

Transcripts

play00:00

asynchronous javascript callbacks

play00:03

promises async await huh this was one of

play00:06

the most difficult concepts for me to

play00:08

learn in javascript but don't worry

play00:10

because we'll break it all down in about

play00:11

10 minutes all right first off if you're

play00:14

new to the channel welcome my name is

play00:16

jamesquick

play00:16

and every week i do one to two and

play00:18

sometimes three videos on web

play00:20

development

play00:21

including topics like asynchronous

play00:23

javascript which i am really excited

play00:24

about because

play00:26

asynchronous javascript learning how how

play00:28

and why javascript is asynchronous and

play00:30

how to work with it

play00:31

is one of the most important concepts

play00:33

you can learn in javascript specifically

play00:36

it makes javascript as a language a

play00:37

little bit more unique in comparison to

play00:39

other languages

play00:40

and it really is just core to how

play00:42

javascript works and the javascript

play00:44

that you will be writing in your

play00:45

day-to-day so there's three different

play00:47

categories

play00:48

commonly of asynchronous javascript

play00:51

we'll start off with callbacks we'll

play00:52

talk about those

play00:53

then we'll get into promises and we'll

play00:55

talk about those

play00:56

and then we'll talk about async await

play00:58

which is a newer feature in javascript

play01:00

that really

play01:01

kind of streamlines the process of

play01:03

writing asynchronous code and is my

play01:05

personal preferred way to write

play01:07

asynchronous javascript

play01:08

so make sure you stick around to the end

play01:10

to know how to write javascript

play01:12

asynchronous javascript in the latest

play01:14

and greatest

play01:14

and my favorite way so let's go ahead

play01:18

and get started and i've got lots of

play01:19

different callouts in here for different

play01:21

things we're going to do

play01:22

let's start with the idea of a callback

play01:24

and an example of this is one we've

play01:26

probably seen

play01:27

many times it's where we can do a set

play01:29

timeout for example

play01:30

and a set timeout will take a callback

play01:33

function and you've probably heard that

play01:35

term in that sense before

play01:36

and in this case what we're saying is

play01:38

we're calling timeout we're passing it

play01:40

this function which will log out

play01:41

waited for one second and we're telling

play01:43

it how long to wait before it does that

play01:45

which is in this case

play01:46

one second which is a thousand

play01:47

milliseconds so we save this and after

play01:49

about a second we should see that

play01:51

message come up

play01:52

now this is asynchronous because we tell

play01:53

it hey in the future javascript lan

play01:56

node call this function after the

play01:58

appropriate amount of time that's why

play02:00

that is java or that's why that is

play02:02

asynchronous it's also javascript

play02:04

so i want to give you a little bit

play02:06

deeper of an example here where you can

play02:08

have

play02:08

nested set timeouts and this gets uh

play02:11

into an example of

play02:12

demonstrating the callback hell that you

play02:15

can get into and you get into this kind

play02:17

of like christmas tree pattern but

play02:19

you have a callback function here and

play02:22

that thing is waiting a second and then

play02:23

logging out three and then inside of

play02:25

that you call a function that then takes

play02:27

a callback function inside of that one

play02:29

you then have a callback function

play02:30

so this is callback hell where you're

play02:32

nesting and nesting and nesting this

play02:33

stuff and this will do maybe what you

play02:35

expect where it'll do wait a second then

play02:37

do three

play02:37

two one and then you're on so those are

play02:40

your traditional callbacks are a

play02:42

traditional

play02:43

kind of simple examples you could also

play02:44

have something like this where if let's

play02:46

say we had a button

play02:48

in browser javascript and we called

play02:51

button.addeventlistener

play02:53

and we listened for the click event and

play02:55

then passed it

play02:56

a callback function and this is another

play02:59

example of a callback where we register

play03:02

for this event and then our handler the

play03:05

callback here

play03:06

is this part here now this code is

play03:09

running in node so i don't have access

play03:10

to the dom and dom

play03:11

element so i'll get rid of this just

play03:12

wanted to show you that that's another

play03:14

example

play03:15

a common example of callbacks in

play03:18

javascript let me comment this one out

play03:20

so now let's talk about the idea of an

play03:22

error first callback this is where

play03:24

all the code that we've run so far in

play03:26

those callbacks there's not really much

play03:27

of a chance for anything to go wrong but

play03:29

what if it does

play03:31

so let's do an fs.read file

play03:34

and i've imported the fs module up here

play03:36

as well as

play03:37

a node fetch we'll talk about that in a

play03:39

minute and the fs module is the file

play03:41

system module

play03:42

inside of node so in this case we're

play03:44

wanting to read a file

play03:46

so let's do an fs read file

play03:49

we'll tell it which file we want to read

play03:51

we'll tell it what kind of

play03:52

encoding we want to convert it to which

play03:55

in this case is utf-8

play03:57

and then we'll have a callback that

play03:58

takes two properties

play04:00

an error property as the first one or

play04:02

parameters error as the first one and

play04:04

then data as the second one

play04:05

and the reason is you might fail to

play04:07

actually read this file so if we just

play04:09

start with logging out

play04:10

data and it's done correctly you can see

play04:12

it has the text here from

play04:15

that text file and hey this is an

play04:17

awesome video that's cool

play04:19

but what if something goes wrong what if

play04:20

we type in test.2 well it's saying

play04:22

undefined here because there is no data

play04:24

because an error happened

play04:26

so a traditional way that you'll see a

play04:28

lot of this code is something

play04:29

like this and i'll just kind of paste in

play04:31

this example where you first

play04:33

check for an error so if there is an

play04:35

error property log that out and then do

play04:37

whatever you want otherwise you can

play04:39

assume the data is good

play04:41

so in this case it logs out the data and

play04:42

then if we uh through an

play04:44

error here it will handle that thing and

play04:47

then log it out with this log here

play04:49

and again it's throwing an error because

play04:50

this is a file that doesn't exist

play04:53

all right so that's the idea of an error

play04:55

first callback and that's really

play04:56

important when we get into promises and

play04:58

async await is these things that are

play05:00

asynchronous

play05:01

sometimes things go wrong and we need to

play05:03

be prepared to handle those errors

play05:05

all right now let's talk about promises

play05:07

which is kind of like the evolution of

play05:09

the idea of callbacks and i want to

play05:10

start by creating a promise

play05:12

so by creating a promise you're passing

play05:14

it a function

play05:15

that accepts both a resolve and a reject

play05:18

callback basically and then in your code

play05:21

you want to detect whether or not this

play05:22

thing is successful or it failed and

play05:24

then if it's successful you call resolve

play05:26

if it rejects if it fails you call

play05:28

reject and so i'm going to take a little

play05:30

bit of snippet here to get a random

play05:32

number that is either a zero or a one

play05:36

and then i'll say if the random number

play05:38

is

play05:39

zero i'm going to consider that to be a

play05:41

good

play05:42

thing so i'll call resolve else i'll

play05:45

call

play05:45

reject so again promises always have a

play05:48

success path and a fail path

play05:50

referred to in this case as resolve and

play05:52

reject and then we'll see what that

play05:54

becomes when we use

play05:55

a promise in a second so since we have

play05:58

this promise we can call the dot

play06:00

then and dot then will take

play06:04

a callback function where we can log

play06:07

something like

play06:08

success and we'll save this and we'll

play06:10

refresh and we start by saying that

play06:11

there was an unhandled promise rejection

play06:13

so let's save again

play06:14

then we see success and success and

play06:17

unhandled promise exception

play06:19

the reason is that when we use this

play06:21

promise remember it can resolve or

play06:23

reject

play06:24

the the dot then in this case passing

play06:26

this handler

play06:28

to the dot then is only handling the

play06:30

success case

play06:31

if we want to handle the bad case the

play06:33

error case it's a dot

play06:35

catch and then we can do a callback

play06:38

function here

play06:39

with a console error of something

play06:42

went wrong all right so now we say this

play06:45

say this you see something went wrong

play06:47

and then something went wrong and then

play06:48

success so we're handling both of those

play06:50

so we create a promise with a function

play06:52

that takes in resolve and reject

play06:55

and then based on the action that goes

play06:57

inside of this function

play06:59

you or the promise itself will decide

play07:01

whether or not that's actually

play07:02

successful or not

play07:04

all right so that is us creating a

play07:06

promise but what if we just wanted to

play07:07

use

play07:08

an existing promise well we can use in

play07:10

the fs modules there is a promises

play07:13

set of functions where we can call read

play07:16

file

play07:17

in the same way we just did all right so

play07:20

this would be doing fs.promises and then

play07:22

calling read file the exact same way

play07:24

that we just did

play07:24

and now instead of using callbacks we

play07:26

can handle the dot then

play07:28

and the dot catch and you'll notice uh

play07:31

often you see

play07:32

uh these returned on a new line for

play07:33

readability and that's a really good

play07:35

habit to get into

play07:36

so if this success successful we'll get

play07:39

the data back and we can log that out or

play07:42

there

play07:42

is a dot catch for an error

play07:45

and then we can air that out all right

play07:48

so there's our text if it passes and

play07:50

then if it fails if we did a test.2

play07:53

now you see that this thing is handling

play07:54

the error so this little snippet up here

play07:57

is how we do

play07:58

read files with promises versus

play08:01

this one up here and you can tell that

play08:03

this is a little less code that we're

play08:05

having to write with promises so this is

play08:06

kind of an upgrade here

play08:08

now another good example of promises is

play08:11

with the fetch api

play08:12

and fetch api is how we make xhr

play08:15

requests to a server

play08:16

and a good fun example of that that i

play08:18

like is using the pokemon api

play08:20

so you can call the pokemon api and you

play08:22

can get some information about a pokemon

play08:24

back

play08:24

so if we want to use that inside of node

play08:27

there's a node

play08:28

fetch package that i have installed so

play08:30

that we can do fetch the same way we

play08:31

would inside of browser javascript

play08:33

so we'll paste in that url and then just

play08:36

like what we just saw we can actually

play08:38

copy this you can see that that promises

play08:41

will

play08:41

follow a pretty similar format well

play08:43

we'll have

play08:44

a success case which is in the dot then

play08:46

and then we'll have the uh not success

play08:48

case which is in the

play08:50

catch so you can see this is successful

play08:52

it gives us back lots of information

play08:54

about our response but it's not quite

play08:56

actually the data that we're looking for

play08:59

so actually what happens is this gives

play09:01

us back a response

play09:02

and then what we want to do is get the

play09:04

json out of that response

play09:06

and getting the json out of that

play09:07

response happens to return a promise

play09:10

which means we can then chain on another

play09:13

thing here

play09:14

where we're going to get the actual data

play09:16

so then we'll log out

play09:18

the data and we should see that that

play09:20

comes back with

play09:21

abilities and name and url so let's take

play09:23

a second to break this down again

play09:25

we call fetch we handle the success case

play09:28

with dot then

play09:29

we get the response which is just the

play09:31

raw response that comes back and then we

play09:32

need to convert that thing to json

play09:34

so res.json returns a promise then we

play09:37

can

play09:38

chain on a promise dot then to handle

play09:41

that promise

play09:42

and then we get the actual data and we

play09:43

log it if this

play09:45

were to be bad it would trigger

play09:48

our catch so you can see if we typed in

play09:51

something like undefined

play09:53

you can see that that is going to throw

play09:54

an error it says invalid json but we're

play09:57

able to handle that

play09:58

inside of our catch all right so now i

play10:01

want to show you

play10:02

the evolution of promises to async await

play10:04

this is my favorite way to write

play10:06

asynchronous javascript this is the way

play10:07

that i

play10:08

always do this so i'm going to copy in a

play10:10

snippet here this is going to be an

play10:11

updated snippet

play10:13

of our load file work that we've done in

play10:15

the past

play10:17

all right so this is going to be an

play10:18

updated snippet of the read

play10:20

file so this is going to be an updated

play10:22

snippet of the read file stuff that

play10:24

we've done a few times now

play10:26

all right so now in this case what we're

play10:27

doing is we're defining a load file

play10:29

function and the reason is if we want to

play10:31

use

play10:32

this async await capability we have to

play10:34

mark a function as async so this is

play10:37

looks like a regular arrow function

play10:39

except we add the async keyword

play10:41

so now this is an asynchronous function

play10:43

which means inside of this

play10:45

we can use the await keyword so what

play10:47

will happen

play10:48

is we'll call our fs promises read file

play10:51

the same way we did before

play10:53

but instead of passing callbacks or

play10:55

doing a dot then to handle the responses

play10:57

we add the await keyword and we get our

play10:59

data right here that's really cool this

play11:01

is much more streamlined and a lot more

play11:03

readable for me especially or this is

play11:05

my preference in terms of readability so

play11:08

now if we save this

play11:09

uh we'll get this is an awesome video so

play11:11

we see that response coming back again

play11:12

so all that is working

play11:14

but the problem is what if we do an

play11:16

error here what if we do test.2

play11:18

well that actually throws an error and

play11:20

that's where we take this one step

play11:21

further

play11:22

where we have a try catch and so what a

play11:25

try catch is saying

play11:26

it's like hey let's go ahead and try to

play11:29

run some code which will be this code

play11:30

here

play11:31

if some sort of error happens now we can

play11:33

handle

play11:34

that error inside of this catch this way

play11:38

so we'll log this thing out in this case

play11:40

what this should do is it should safely

play11:42

handle this response

play11:43

log out the air but we're still able to

play11:45

use our async await functionality

play11:47

again i love async await this is code

play11:49

that i write all the time

play11:51

inside of my personal javascript code

play11:54

all right so let's take this uh one

play11:56

last up further and i'm gonna copy in

play11:58

the fetch pokemon

play11:59

example so here's our new fetch pokemon

play12:02

function and it will make a fetch

play12:05

request the same way we saw before

play12:07

except it's awaiting that response

play12:09

getting the response here

play12:11

and then it's awaiting the res.json

play12:13

remember that this res.json returned a

play12:16

promise before

play12:17

so now we can await that response the

play12:19

same way we do the original fetch

play12:20

request so we make the request we await

play12:22

the response

play12:24

we take the response we convert it to

play12:25

json and we await that

play12:27

and then we end up getting our data so

play12:30

in this case i'm passing in an id of a

play12:32

pokemon and then making that request we

play12:34

should see that we get information

play12:35

coming back but

play12:36

what if we pass in nothing which would

play12:39

then make this id undefined

play12:41

and throw an error we're not handling it

play12:43

and you'll see that we get an unhandled

play12:45

promise exception here

play12:46

which means that we need to go and

play12:49

handle this with our try catch so the

play12:51

same way we did this before

play12:53

here's our try this is the code that we

play12:54

want to try and then we'll catch an

play12:56

error and then error that

play13:00

error out if there is one so now you can

play13:02

see that it throws that or it

play13:04

logs out or errors out that error

play13:07

appropriately

play13:08

just like we did with our read file but

play13:10

now this is the type

play13:12

of asynchronous javascript that i prefer

play13:15

to use i love using async await myself

play13:17

i use async weight in every instance

play13:19

that i can i

play13:21

almost never use callbacks if i can

play13:23

avoid it and there are some things that

play13:24

you can do

play13:25

to kind of convert older callbacks to

play13:27

promises

play13:28

so you can look that up or if you're

play13:30

interested in knowing how to do that let

play13:31

me know in the comments but i will

play13:33

always use

play13:33

async await in my javascript i'm curious

play13:36

if you've seen

play13:37

these different formats for doing

play13:38

asynchronous javascript what is your

play13:40

favorite callbacks promises

play13:42

async await let me know in the comments

play13:45

which one of those you prefer

play13:46

hopefully you enjoyed a lot in this

play13:47

video about a cool

play13:49

challenging topic in asynchronous

play13:51

javascript and i'll see you in the next

play13:53

video

Rate This

5.0 / 5 (0 votes)

関連タグ
JavaScriptAsynchronousCallbacksPromisesAsync/AwaitWeb DevelopmentTutorialProgrammingNode.jsCoding Tips
英語で要約が必要ですか?