Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0b6afe

Browse files
Question-Answer- 51
1 parent 44cca84 commit f0b6afe

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Top JavaScript interview questions
5656
| 48 | [What is an event loop](#48-what-is-an-event-loop) |
5757
| 49 | [ES6 and its features](#49-es6-and-its-features) |
5858
| 50 | [Difference between function and method](#50-difference-between-function-and-method) |
59+
| 51 | [What is aync and await](#51-what-is-aync-and-await) |
60+
5961

6062
### 1. What is JavaScript
6163
* JavaScript is a scripting language used to create dynamic and interactive websites. It is supported by all major web browsers.
@@ -772,6 +774,18 @@ function sum(a, b) {
772774
}
773775
sum(2,4);
774776
```
775-
******************************In progress
777+
778+
### 51. What is aync and await
779+
async/await is a feature in JavaScript that allows us to write asynchronous code that looks more like synchronous code. "await" works only inside "async" functions
780+
781+
"async" ensures that a function returns a promise and "await" pause the execution of the function until a promise is resolved or rejected.
782+
```js
783+
const getData = async () => {
784+
const response = await fetch('https://api.openweathermap.org/data/2.5/weather?q=New%20York&appid=YOUR_API_KEY');
785+
const data = await response.json();
786+
console.log(data);
787+
}
788+
getData();
789+
```
776790
777791

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /