JavaScript Async Await

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ก.ย. 2024
  • One of the hardest things about writing good JavaScript is dealing with heavily nested asynchronous code. Promises were created to solve the problem with callback hell, but there are still plenty of nested problems related to promises. This is where async/await comes in. JavaScript added async/await to allows developers to write asynchronous code in a way that looks and feels synchronous. This helps to remove many of the problems with nesting that promises have, and as a bonus can make asynchronous code much easier to read and write. In this video I am going to explain what async/await is and how to use async/await to rewrite your existing promise based code.
    Learn Promises First:
    • JavaScript Promises In...
    Async/Await Article:
    blog.webdevsim...
    Twitter:
    / devsimplified
    GitHub:
    github.com/Web...
    CodePen:
    codepen.io/Web...
    #JavaScript #AsyncAwait #Promises

ความคิดเห็น • 767

  • @muhammadsafiullah8428
    @muhammadsafiullah8428 5 ปีที่แล้ว +864

    I showed this video to my crush and she's my wife now. I'm grateful, thanks for sharing this video with us.

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว +559

      I didn't realize I had so much power within my videos. I need to show this to my girlfriend :P.

    • @the-mush
      @the-mush 4 ปีที่แล้ว +95

      @@WebDevSimplified aaaaand, now she's pregnant (o_O)

    • @mhshoghi
      @mhshoghi 4 ปีที่แล้ว +12

      @@WebDevSimplified Perfect . :))

    • @the-mush
      @the-mush 4 ปีที่แล้ว +4

      @@pearlsswine it is black and has ginger curly hair, what does this mean? D:

    • @kofuku1344
      @kofuku1344 4 ปีที่แล้ว +127

      Did the same, now I'm single

  • @evanoshea9506
    @evanoshea9506 ปีที่แล้ว +23

    I've been watching all your videos. Nobody else on youtube has coding videos so succinct and efficient to watch. Thank you for valuing the time of your viewers!

  • @woehrle17
    @woehrle17 2 ปีที่แล้ว +9

    I'm in a web dev bootcamp currently and you're videos are amazingly helpful, thanks so much.

  • @prathameshyadav2001
    @prathameshyadav2001 3 ปีที่แล้ว +57

    I don't comment usually but this video is on another level. Spent hell lot of time understanding promises and async-await and after watching this video I am feeling like how foolish I was not to understand this simple concept 😂

  • @jeffdesouza6667
    @jeffdesouza6667 ปีที่แล้ว +3

    Thanks! I leaned heavily on your videos while I was in a bootcamp and now have a good paying job! Thank you so much for your help -- I've been meaning to buy you a beer for some time

    • @WebDevSimplified
      @WebDevSimplified  ปีที่แล้ว +1

      Thanks! I am glad to hear you landed a good job.

  • @rebelmachine88
    @rebelmachine88 5 ปีที่แล้ว +632

    This is definitely one of the best, simplest explanations I've seen of async/await. Thank you!

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว +29

      Thanks! I am really glad you enjoyed it.

    • @vinubox
      @vinubox 4 ปีที่แล้ว

      Sure !

    • @mr.prince8701
      @mr.prince8701 4 ปีที่แล้ว +1

      @@vinubox It really is. It's short but effective.

    • @latinstuff1
      @latinstuff1 2 ปีที่แล้ว +7

      thats what everybody says in every tutorial in youtube lol I trust you and im sure this is an epic and amazing explanation but its funny to see the same comment in every tutorial.

    • @rebelmachine88
      @rebelmachine88 2 ปีที่แล้ว +2

      @@latinstuff1 lol you're not wrong about that! Ppl tend to absorb information differently, so it makes sense it would be a common comment on tricky subjects.

  • @asthayadav4931
    @asthayadav4931 4 ปีที่แล้ว +1

    Went through 2-3 different videos but the way you explained async await (and promises in a diff video ) is way too good. Thanks!

  • @roymargalit2660
    @roymargalit2660 3 ปีที่แล้ว

    this is mind boggling. i am overwhelmed by how much easier this is.
    thanks man!!

  • @MonsterFishKeepersPH
    @MonsterFishKeepersPH ปีที่แล้ว

    man I love how you explain things so clearly

  • @bhavesh2952
    @bhavesh2952 3 ปีที่แล้ว +1

    You are a legend buddy :) Thank you. no intro and all like other TH-camrs.. directly to the point

  • @heliodasilvajr.8981
    @heliodasilvajr.8981 3 ปีที่แล้ว +1

    This is by far the best explanation/example about async/await.
    Thank you so much. 👍😉

  • @krisashehi5144
    @krisashehi5144 3 ปีที่แล้ว

    Ive been struggling to grasp async and await for a couple of days. This video made it so easy, thank you!

  • @bjmaldonado
    @bjmaldonado 4 ปีที่แล้ว

    Well paced and not convoluted. Thanks!

  • @moinkhan-xd6pe
    @moinkhan-xd6pe 4 ปีที่แล้ว

    I must say you great man ...really a great video easy and simple to understand Asyn await.Thank You bro

  • @alexandroskourtis5268
    @alexandroskourtis5268 4 ปีที่แล้ว

    simple and straight to the point

  • @shwetakumari9940
    @shwetakumari9940 2 ปีที่แล้ว

    you make one of the best videos on any topic

    • @Hafsa0526
      @Hafsa0526 2 ปีที่แล้ว

      Hello Shweta, do you frequently learn from these videos? Would you be interested in exploring an opportunity in web development?

  • @rustyrage4197
    @rustyrage4197 4 ปีที่แล้ว

    one of the best videos on async functions

  • @sayyedadeebhussain5345
    @sayyedadeebhussain5345 3 ปีที่แล้ว

    New user of your channel, but impressed with your clarity.
    I had to Subscribe you as a Thanks giving :)

  • @krtirtho
    @krtirtho 4 ปีที่แล้ว +1

    Little misunderstanding: Async & Await keywords are used to simplify the "then/catch hell chain". if you have a promise inside a another promise inside another promise and on and on it might look bit confusing and this is "callback hell" for callback based API such as NodeJS and "then/catch hell" for Promise Based APIs. Async & Await is only another way to execute Promises. It's not a type of Promise/Asynchronus_Code_Executor (e.g:Callbacks) iteself. It's just an executor which let us mitigate the code complexity of traditional callback/then/catch chain and use Promises as simple as using a Synchronus variable in a Function. So comparing async/await to Promise is kind of comparing a car with its steering wheel. But Async/Await vs. Then/Catch suits...
    Please Kyle, make another video about this and explain your horrible mistake & I know you know that too. Don't create misconceptions. Otherwise it will lead us too uncertainity and hence we will end up doing nothing. Even I was arguing with one of my senior and he checked your video when I referenced it to him and then explained the whole scenerio & with proves. So please fix it..

    • @RyanValizan
      @RyanValizan 4 ปีที่แล้ว

      KR. Tirtho This makes more sense, I did not understand the reasoning for await in the scenario he is describing here. The code is already loading in that order, you’ve just made it easier to read now.
      *edit* actually, no...no, that doesn’t explain the awaits being used in this scenario at all.

  • @AJD...
    @AJD... 3 ปีที่แล้ว +1

    Thank you so much! I finally understand Promises, Async & Await. Glad I found your video!!!

  • @tym20021
    @tym20021 3 ปีที่แล้ว

    Saving my mental state as always. Thanks bro

  • @prasunkj
    @prasunkj 3 ปีที่แล้ว

    simplest explanation of the complicated logic!! thanks a ton!!

  • @franciscofuentes8916
    @franciscofuentes8916 2 ปีที่แล้ว

    Thank you I always wanted to understand what all the fuss was about promises and it turned out to be pretty simple. Also tons of videos and tutorials make it seem complicated to understand.

  • @nizamuddinshaikh3185
    @nizamuddinshaikh3185 4 ปีที่แล้ว +1

    You are making wonderful tutorials, I must say, for topics ranging from the basic to the most advanced level of JavaScript Programming. I value the simplicity and straightforwardness of topic explanation. Kudos for your hardwork and efforts.

  • @tojal
    @tojal 3 ปีที่แล้ว +1

    This is a great explanation of Async/Await, but I must say that Thumbnail you used is very misleading! I got in thinking that Async/Await substituted Promises completely. The truth is it only substitutes the .then.catch section of Promises. Still great explanation, I just think that difference should be clearer :) Cheers!

  • @sagargopale5747
    @sagargopale5747 4 ปีที่แล้ว

    Very well explained. Easy to understand.
    Thanks

  • @rebazmohsen9442
    @rebazmohsen9442 2 ปีที่แล้ว

    You are killing it man👍

  • @ragulmurugesan7182
    @ragulmurugesan7182 3 ปีที่แล้ว

    You are the best. Super explanation and example buddy 👌

  • @yaolegoleynik
    @yaolegoleynik 5 ปีที่แล้ว +1

    Incredibly simple and understandable explanation thank you!

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว

      You're welcome! I am really glad I could help.

  • @jokosalsa
    @jokosalsa 3 ปีที่แล้ว

    Thank you....finally someone explain it clearly. Subscribed!

  • @stith_pragya
    @stith_pragya ปีที่แล้ว +1

    Thank You So Much BROTHER............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @rahultirkey7950
    @rahultirkey7950 4 ปีที่แล้ว

    I understand the whole thing. Keep making more tutorials like that.

  • @Metruzanca
    @Metruzanca 5 ปีที่แล้ว

    ohhhhhhhhhhhhhhhhhhhhhhh
    Btw, this and the previous are the best promise tutorials on youtube. Straight and to the point.

  • @user-or7ji5hv8y
    @user-or7ji5hv8y 3 ปีที่แล้ว

    concise and clear. but is it mainly used in javascript?

  • @ypqfyf
    @ypqfyf 5 ปีที่แล้ว +1

    Thanks mate, it's really helpful and easy to understand!

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว

      You're welcome. I'm glad you enjoyed the video.

  • @alandre
    @alandre 4 ปีที่แล้ว

    Thx god for you to exist

  • @experimentaltau8477
    @experimentaltau8477 3 ปีที่แล้ว

    Thanks buddy for awesome explanation

  • @marcinkalmar9964
    @marcinkalmar9964 2 ปีที่แล้ว

    Really good explanation , time saved :)

  • @KanagaveluSugumar
    @KanagaveluSugumar 2 ปีที่แล้ว

    Excellent!!! Thank you!!
    The code snippet is missed, so cannot copy and try.
    Do you have video on how to use these concepts in AWS Lambda? Because these concepts really helpful there.

  • @meditationheathandwellness781
    @meditationheathandwellness781 3 ปีที่แล้ว

    Excellent video. Thanks for your incredibly good content and bright ideas

  • @rakesh989
    @rakesh989 4 ปีที่แล้ว

    This is amazing. Simple and clear!

  • @ThijmenCodes
    @ThijmenCodes 4 ปีที่แล้ว

    Awesome video, love the pace!

  • @dshcfh
    @dshcfh 2 ปีที่แล้ว

    I did it with your help, thank you my boy

  • @diogo9610
    @diogo9610 4 ปีที่แล้ว

    Good job, very clear video

  • @ashappyas6415
    @ashappyas6415 4 ปีที่แล้ว

    Excellent video!

  • @polikalepotuaileva6006
    @polikalepotuaileva6006 4 ปีที่แล้ว

    Ah awesome! Thanks so much you made it so easy to understand!!

  • @maya34
    @maya34 4 ปีที่แล้ว

    Great video! Thank you so much. :)

  • @mathiasburgio8810
    @mathiasburgio8810 3 ปีที่แล้ว

    thaks for all your videos!

  • @n335t3r
    @n335t3r 6 หลายเดือนก่อน

    I'm learning with ODIN Project. Async/await seems way easier to work with than Promises.

  • @Tesseract9630
    @Tesseract9630 3 ปีที่แล้ว

    omg this is such a great video.

  • @ribl1000
    @ribl1000 3 ปีที่แล้ว

    You rock dude.

  • @pahvalrehljkov
    @pahvalrehljkov 4 ปีที่แล้ว

    dude... amazing...

  • @jivanmainali1742
    @jivanmainali1742 5 ปีที่แล้ว

    I have come here after watching fetchapi and it is mindblowing

  • @paristar3079
    @paristar3079 4 ปีที่แล้ว

    You made it easy

  • @reclearning558
    @reclearning558 4 ปีที่แล้ว

    This was awesome

  • @dustintravis8791
    @dustintravis8791 5 ปีที่แล้ว

    Another great tutorial, thanks again g!

  • @laufgas
    @laufgas 4 ปีที่แล้ว

    Great video, but I am a bit confused because around 3:45 you say the await keyword makes the async function to wait for the makeRequest to finish, but then you say around 4:10 the async function won't wait for the await function and keep on going. If you could clarify it would be helpful. Thanks

    • @z9607
      @z9607 4 ปีที่แล้ว

      He said that because doWork() is an asynchronous function, which means doWork() function will run in the background and it will keep running (if any) more code after the doWork() function (not the doWork() content but all the code after closing the doWork() function bracket: doWork(){...} --> 'more_code'). The only code that will wait to run is the code that is inside the doWork() function, the code after the await statement since the program cannot run that code until the result is returned.

  • @abhinavs2484
    @abhinavs2484 ปีที่แล้ว +1

    Neat!!

  • @tasinhoque3003
    @tasinhoque3003 4 ปีที่แล้ว

    It really helped!

  • @RubberDuckCoding
    @RubberDuckCoding 2 ปีที่แล้ว

    VERY NICE!

  • @Ouchie
    @Ouchie 3 ปีที่แล้ว

    TIL you can use async await when returning promise.

  • @ShinAkuma
    @ShinAkuma 4 ปีที่แล้ว

    How are promises and async different from normal procedural approach ?
    All of this code can we done without using promises or async and it will work just the same, so what is different ? where should I be using them ?

  • @surendrareddyseelam9757
    @surendrareddyseelam9757 4 ปีที่แล้ว

    Thanks kyle🙏🙏🙏🙏

  • @cvvkshcv
    @cvvkshcv 5 ปีที่แล้ว

    Great! simple and clear

  • @necrorifter3059
    @necrorifter3059 3 ปีที่แล้ว

    Was it changed because console.log('Making Request to ${location}') no longer replace the location with the correct variable? Replace that with console.log('Making Request to '+location) to make it work, same for the ${response} part.

  • @pastorfred2543
    @pastorfred2543 5 ปีที่แล้ว +63

    Thanks Sir, I appreciate the way you've made it look it simple. Now my fears are gone.. I will use Promise and Async Await in my projects.

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว +10

      I'm really glad my video was able to help!

  • @monfernape
    @monfernape 5 ปีที่แล้ว +145

    Hey how did you make it so simple? Thanks

    • @vinubox
      @vinubox 4 ปีที่แล้ว

      Exactly!

  • @stromblessed
    @stromblessed 5 ปีที่แล้ว +47

    Great video, Simple and easy to understand tutorial. Thanks man.

  • @OfChaoticReign
    @OfChaoticReign 4 ปีที่แล้ว +18

    People like you are why I love the JavaScript community. I still hate the language, but I love this community. Thanks for posting this!

    • @gabrielaperez42
      @gabrielaperez42 3 ปีที่แล้ว +2

      hahahaha this comment represents me a lot!

  • @justmeldin6062
    @justmeldin6062 5 ปีที่แล้ว +86

    Even thou you speak fast, somehow I can completely grasp the topic. The name of the channel is right on point. Keep it up : )

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว +8

      I'm really glad you were able to understand the topic.

    • @keremardicli4013
      @keremardicli4013 3 ปีที่แล้ว +1

      Fireship and wds channels are meant to be watched on 0.75x playback speed.

  • @franciscopena1140
    @franciscopena1140 ปีที่แล้ว +13

    I like how you go straight to the point. Thanks

  • @maximofernandez196
    @maximofernandez196 2 ปีที่แล้ว +13

    Man, I cannot tell how good you explain. The best part is that you explain the WHY of the things that happen. Really, amazing work

  • @todordonev
    @todordonev 3 ปีที่แล้ว +7

    I dont usually write comments in youtube but.. damn..
    By chaining your videos one after another explaining different concepts I now understand all this javascript spaghetti. Also your videos are very high quality and you are a very good explainer.

  • @TheMr0450
    @TheMr0450 4 ปีที่แล้ว +9

    Dude.. async/await and promises had scared me for years.. uve made me understand them in 17 mins.. much much appreciated...

  • @mostinho7
    @mostinho7 2 ปีที่แล้ว +1

    Done thanks
    Promises are just JavaScript way of chaining callbacks (do this, then when its done do this etc). Instead of nested callbacks, which leads to callback hell, promises allow you to do .then(…).then(…) but each lambda in these .then should return a Promise object to be able to call .then on it.
    Async await is doing the same thing but in cleaner way. Await is NOT blocking, it lets js execute other code then when the code we are awaiting finishes js can come back and continue (how? With the event loop) The awaits are wrapped in an async function (function with async keyword before it).
    You await a promise. Await someFunctionThatReturnsAPromise()Can catch errors with try catch when promise you are waiting on is rejected

  • @codewithbishal895
    @codewithbishal895 3 ปีที่แล้ว +9

    web dev Simplified and dev Ed this 2 guys literally taught me everything

  • @TechRedstone
    @TechRedstone 3 ปีที่แล้ว +1

    for some reason js ignores my await and continues with the code anyway.
    const inv = await getPlayerInv(message.author.id);
    console.log(inv);
    just like you did but a console.log in getPlayerInv(); fires off first

  • @keshavgera8108
    @keshavgera8108 3 ปีที่แล้ว +1

    nice great explanations Thank You... continue... Please add one more video i have some doubt what is useLayoutEffect and why we use useLayoutEffect in react-native hooks

  • @IfadArdinx
    @IfadArdinx 4 ปีที่แล้ว +13

    I watch your video everytime i'm about to start a section in Codecademy. You give the simple explaination of the concept while the Codecaemy provide the practice. Such a great combo! Thank you!

    • @brandonbh04
      @brandonbh04 ปีที่แล้ว

      How long after starting to learn did it take you to get your first job?

    • @natasdabsi1138
      @natasdabsi1138 7 หลายเดือนก่อน

      @@brandonbh04 1 year

  • @c0deventures
    @c0deventures 3 ปีที่แล้ว +1

    Async/await being better than promises doesn't mean anything! In fact, async/await is a syntax sugar that makes use of Promise underneath.

  • @iosaroj
    @iosaroj 2 ปีที่แล้ว +1

    If I have a for loop which iterates more than 500 time inside which I am doing this kind of operation, in case of any performance issue will it cause the browser window to hang ?

  • @fabiorengel
    @fabiorengel 2 ปีที่แล้ว +5

    I am learning JS and React and always works for me seeing your videos after some classes. Thank you.
    But, if I may say, would be even better if make the code you wrote available throughout some link. That way would be even easier to make some tests based on you examples.
    Thank you, again.

  • @user-kn5yr2vu7k
    @user-kn5yr2vu7k 4 ปีที่แล้ว +6

    Thank you, by far the best and easiest to understand explanation i've found. I also watched your video on promises, very well explained!

  • @rubeushagrid4131
    @rubeushagrid4131 3 ปีที่แล้ว +1

    1 followup question : Why are we consistently using const keyword everytime we are storing an object ? You could also use var or even let keywords. Is there any significance of using const keyword over other similar keywords?

  • @techstuff7568
    @techstuff7568 2 ปีที่แล้ว +33

    I was avoiding async/await for so long because I thought it was complicated and I was doing fine without it. Finally looked into it and wow it's simple and clean. Thanks for the great tutorial!

  • @Philson
    @Philson 3 ปีที่แล้ว +1

    Does the variable need to be const? So many const in the codes.

  • @Digital963
    @Digital963 3 ปีที่แล้ว +1

    this was very helpful, as well as your promises video. Much appreciated, thanks!

  • @finnritslev4559
    @finnritslev4559 4 ปีที่แล้ว +1

    You could be doing far better if you did not speak so fast.

  • @nguyenhanh9479
    @nguyenhanh9479 3 ปีที่แล้ว +1

    why is it so easy to understand, what is happening ????

  • @snowplow8418
    @snowplow8418 ปีที่แล้ว +13

    You take a concept, boil it down into its essence and explain it using the most basic and easy to understand example. Incredible videos. By far the best channel on YT for this.

    • @williamdevonshire356
      @williamdevonshire356 ปีที่แล้ว +2

      i know right? the other ones end up confusing me with all sorts of seemingly unrelated and complex additions, whereas his vids just say what need to be said and are understandable without and unnecessary and difficult additions

  • @aabedkashwa9125
    @aabedkashwa9125 5 ปีที่แล้ว +7

    Ok, i am lucky to have you in my life. Thanks for simplifying this!

  • @sadabratakonar4219
    @sadabratakonar4219 2 ปีที่แล้ว +1

    Async Await with Promises and setTimeout
    const photos = []
    async function uploadPhoto() {
    const uploadStatus = new Promise((resolve, reject) => {
    setTimeout(() => {
    photos.push("Profile photo uploaded")
    if (!photos.length) resolve("resolved")
    else reject("rejected")
    }, 2000)
    })
    let res
    try {
    res = await uploadStatus
    console.log(res)
    }
    catch (e) {
    console.log(e)
    }
    }
    uploadPhoto()

    • @shivanigaddagimath5994
      @shivanigaddagimath5994 2 ปีที่แล้ว

      Hello Sadabrata! Looks like you were able to learn from this video. Are you a fresher and open to any opportunities in software development currently?

  • @thefireagen
    @thefireagen 4 ปีที่แล้ว +1

    Nicely explained..but a little mishap..
    The code written in the dowork() function is doing some aysncronous work but code execution is still syncronous within that function. Hope it helps.🙂

    • @SaifUlIslam-lw3dm
      @SaifUlIslam-lw3dm 4 ปีที่แล้ว

      but wont aysncronous work will start after the call .... so its nothing wrong i guess

    • @thefireagen
      @thefireagen 4 ปีที่แล้ว

      @@SaifUlIslam-lw3dm
      It surely will...
      But the point i m trying to make here is.. suppose u have 3 or more async work going around within that function...and the very first async is taking longer time to resolve e.g sending emails untill then execution context is holding up there...

    • @SaifUlIslam-lw3dm
      @SaifUlIslam-lw3dm 4 ปีที่แล้ว

      @@thefireagen Yes you are right .... i also noticed that in my code...

  • @michaelionita
    @michaelionita 5 ปีที่แล้ว

    Nice example!
    But, what I always wonder with Promise examples, why are the functions that return the Promises returning immediately?
    I mean this way you don’t need Promises.
    I think for illustration purposes you should use setTimeout() or make an ajax call to jsonplaceholder API to simulate a function that truly does something that is async.
    Still I totally love your videos :)
    Just trying to help.

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว +1

      Thanks for the suggestion. The main reason I kept the code simple was because I didn't want people to need to know other technologies in order to understand this.

  • @TheLMestre14
    @TheLMestre14 5 ปีที่แล้ว +5

    Really enjoyed the video. I already knew how to use async await in javascript, but your video explains it really well and it's much more simpler. Keep it up man ;)

    • @WebDevSimplified
      @WebDevSimplified  5 ปีที่แล้ว +5

      Thanks! I'm really glad you enjoyed the video. There are plenty more like this coming.

    • @IAm-zo1bo
      @IAm-zo1bo 2 ปีที่แล้ว

      i really need to learn more

  • @manojnandhan8677
    @manojnandhan8677 4 ปีที่แล้ว +1

    Simplified solution. Thanks

  • @freivincampbell
    @freivincampbell 4 ปีที่แล้ว +2

    32 people still loving PHP .. jaja
    Thanks so much for your videos, I really love them, you are one of my best favorite channels on youtube. I usually never comment, but this time I had to do it. greetings from Costa Rica

  • @ranellabjata5170
    @ranellabjata5170 2 ปีที่แล้ว +3

    From callbacks to promises and then to async and await. Beginners like me often confused with this three. Thanks for making this three more clear. 👏

  • @TheXuism
    @TheXuism 2 ปีที่แล้ว

    recently I use Axios and encountered tons of async programming itching, thank you for explaining!

  • @AndreyHohutkin
    @AndreyHohutkin 4 ปีที่แล้ว

    A-ha. Let's wrap every method with try-catch! Perhaps, better to put it built-in inside V8?
    What if you want to return a rejected promise?
    Seriously, don't forget - a correct error handling is 80-90% of your code!!!