DEV Community

Cover image for Async and await in JavaScript....?
Narasimma Radhakrishnan
Narasimma Radhakrishnan

Posted on

Async and await in JavaScript....?

Async and await are the JavaScript keywords used to create a asynchronous function or code. Its mainly for clean code, better readability and reusability.

1.Async keyword:
It is used to declare the await keyword used in the async function.
And the function will always return the Promise. if the function returns like string or value it converts or wraps into an resolved promise.

async function greet() {
return "Hello!";
}

2.Await keyword:
This keyword is only used inside async function.
it pauses the function execution until the promise settles(resolve, reject).

Top comments (0)