1 00:00:01,060 --> 00:00:01,820 Hello friends! 2 00:00:01,840 --> 00:00:03,100 Nice to see you back. 3 00:00:03,130 --> 00:00:08,950 In this tutorial we are going to learn two new features of JavaScript async and await. 4 00:00:08,980 --> 00:00:14,890 Let's try to explore what is async function as we make normal functions. 5 00:00:14,890 --> 00:00:16,960 In our case test. 6 00:00:16,990 --> 00:00:23,260 If I type async keyword before the function keyword, then it will become a async function. 7 00:00:23,260 --> 00:00:28,840 But the question is what is the difference between a normal function and a async function? 8 00:00:28,870 --> 00:00:34,600 Async function always return a promise, and we learn about promise in our previous videos. 9 00:00:34,600 --> 00:00:35,950 And we know promise. 10 00:00:35,950 --> 00:00:38,980 Return two type of function resolve and reject. 11 00:00:38,980 --> 00:00:41,410 Based on this we do our further work. 12 00:00:41,410 --> 00:00:47,590 If it resolve, then we call then function, and if our promise is rejected, then automatically call 13 00:00:47,590 --> 00:00:48,670 catch function. 14 00:00:48,670 --> 00:00:51,820 So our async function work like promise. 15 00:00:51,850 --> 00:00:53,970 It may be resolve or reject. 16 00:00:53,980 --> 00:00:59,650 Similarly, we can call then function for resolve and we can call catch function for reject. 17 00:00:59,680 --> 00:01:06,490 Now the question is why we use the async function since we already have the promise method. 18 00:01:06,490 --> 00:01:10,630 If you remember, there is a little complication in our promise method. 19 00:01:10,930 --> 00:01:15,310 Every time we need to declare, resolve, or reject function in promise. 20 00:01:15,520 --> 00:01:20,230 To resolve this kind of complication, JavaScript introduce async function. 21 00:01:20,230 --> 00:01:22,450 It is very easy to operate just. 22 00:01:22,450 --> 00:01:28,510 You need to type async keyword before the function keyword, and you don't need to change in your function. 23 00:01:28,510 --> 00:01:35,350 And I want to tell one thing our promise function introduced in JavaScript, ES6 version and async function 24 00:01:35,350 --> 00:01:39,550 introduce in JavaScript is 2017 version. 25 00:01:39,550 --> 00:01:44,260 From here you can understand why JavaScript introduced async function. 26 00:01:44,290 --> 00:01:47,620 The answer is simple to resolve, promise, complication. 27 00:01:47,620 --> 00:01:53,410 All the things that we could do inside the promise method we can do in async function. 28 00:01:53,410 --> 00:01:57,370 So without wasting your time, let's back to the Visual Studio Code Editor.