Async / Await Basics in JavaScript Explained

Поделиться
HTML-код
  • Опубликовано: 26 дек 2024

Комментарии •

  • @cybergr3g
    @cybergr3g 5 лет назад +1

    Hi, thanks for the video.
    Is there a 'catch' equivalent with await?

    • @JoshuaMorony
      @JoshuaMorony  5 лет назад +1

      With async/await you will be using try/catch to handle errors. I've covered that a bit more in my tutorial on using the Fetch API here: www.joshmorony.com/http-requests-in-stencil-js-with-the-fetch-api/

    • @cybergr3g
      @cybergr3g 5 лет назад

      @@JoshuaMorony Thanks!

  • @georgiyzhuravlev9350
    @georgiyzhuravlev9350 5 лет назад +4

    Hi! Actually, that madly deep nesting shown for `takePhoto` function is not mandatory, you could build nice and flat `.then` chain if you return async functions results (not just call) and use `.catch`. Anyway, thanks for the video, I'm a subscriber! :)

  • @debasisnath9916
    @debasisnath9916 4 года назад +1

    Thanks for the video!!!!!

  • @ChristopherRobertHarris
    @ChristopherRobertHarris 5 лет назад +1

    Josh thanks for the video. Personally I prefer the async / await syntax but I think anyone new to programming should learn the .then syntax first as I think it then makes moving to the async / await syntax easier to understand. But as you say there is nothing wrong with sticking to the .then syntax. I also didn’t know just adding ‘async’ to a function meant it returned a promise, that’s interesting to know.

  • @calorus
    @calorus 5 лет назад

    Very handy video, thanks. Super clear.

  • @nerdcourses32
    @nerdcourses32 3 года назад

    Fantastic