DEV Community

Emily Herr
Emily Herr

Posted on

1

Async Who?

In my journey so far, I realized one of my favorite things javascript does is the async/await function. Learning how functions are called by order really helped solidify the concept for me.

But you may ask, what is the difference? When do I use a regular function and when do I use an async? - The answer lies in what you want to do and what you are working with.

In a synchronous function, javascript implements and reads your code in the order it is writte (that is why Scope is so important!) In async, this tells javascript, "hey do not run this yet, I need more data wait for data to come back to implement the rest."

This is very useful when calling APIs. When you are requesting data from an API, although it seems to come quickly, we do not really know when exactly the API's data will come to you since it is not a data set that you own.

In an async await, you tell the function to wait. In API use-case you tell it to wait until you receive a response and convert it to Json so it is usable.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

๐Ÿ‘‹ Kindness is contagious

DEV shines when you're signed in, unlocking a customized experience with features like dark mode!

Okay