Asynchronous JavaScript: Using the Promise.all and Promise.race Static Methods

Поделиться
HTML-код
  • Опубликовано: 21 авг 2018
  • In this final tutorial on JavaScript promises we will take a look at the all and race static methods. They allow you to work with multiple promises at that same time.
    For more resources on JavaScript:
    www.allthingsjavascript.com
    Full personalized courses on JavaScript:
    allthingsjavascript.com/person...
    Special offer on courses: allthingsjavascript.com/course...
    Tutorials referred to in this video:
    JavaScript Promises Playlist: • Understanding Asynchro...

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

  • @shalomdahal6361
    @shalomdahal6361 5 лет назад +2

    Boss your contents are great!!!
    Thank you!

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

    this are the best tutorials for js ,

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

    Very helpful and clear tutorials

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

    Thank you!

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

    Great like always thank you so much . I have a question out of context but if you can answer anyway please. Is there any problem in run npm install -g more than one time the same library? If yes what is the worst that can happen?

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

      There shouldn't be a problem with doing that. Here is a good article on npm issues that you might find helpful: medium.com/@jacob.h.page/common-npm-mistakes-51bf8989079f

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

    Great video as always!
    I have a question here as well I hope you don't mind answering it.
    In case of race method if either of the promise is resolved or rejected what's happens to others? Are they terminated? Or the execution of the race stops then and there?

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

      Promises can't be cancelled, so basically they are silently ignored.

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

      @@AllThingsJavaScript I was asking if race method finds anyone of them as fulfilled then will the engine go and parse other promises or will exit right away?

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

      @@akshay__sood If one is fulfilled, it ignores the other promises. The other promises are allowed to run to the end as I understand it. Eventually they are garbage collected. Does that help?

    • @akshay__sood
      @akshay__sood 4 года назад

      @@AllThingsJavaScript your replies always help!
      Also in all method I thought when all of them are fulfilled then only it returns output but it outputs only one promise also if either of them are fulfilled.
      I believe for all to be fulfilled we have allSettled.

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

      @@akshay__sood Promise.all for settling all of them.

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

    sir I am beginner.
    var passed=1;
    function globalfun(){
    var inner=4;
    console.log(passed+inner);
    }
    console.dir(globalfun);
    myQ:when I am executing in chrome console there is no closure in last statement.
    but it showing closure in jsfiddle.net of window object(passed). is it closure or not???
    pls provide correct definition sir

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

      Your not really using closure. passed is just a global variable. I think this tutorial that I have done explains closure best: ruclips.net/video/TznpOmv2BQM/видео.html

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

      I m sure you might have found the answer but if in case...
      As far as i know the whole code you write in JS Fiddle is executed in a function so basically the variable that appears to be in a global scope to console is actually a part of a function in JS Fiddle.
      Hope that helps!