Is the Promsise.all () method in ES6 the highest priority and priority in all Promise?

<script>    
   const url="http://127.0.0.1/index.php?id=";
   let task = [];
   let task01 = function(){
        return new Promise( function(resolve , reject){
            $.ajax({
              url: url+1,
              context: document.body,
              success: function(){
                resolve("success");
                 console.log("01");
                }
           });
        })
   }
   task[0]= new Promise( function(resolve , reject){
          $.ajax({
            url: url+2,
            context: document.body,
            success: function(){
              resolve("success");
               console.log("02");
              }
         });
      })
     task[1] = new Promise( function(resolve , reject){
         $.ajax({
           url: url+3,
           context: document.body,
           success: function(){
             resolve("success");
              console.log("03");
             }
        });
     })

    task01().then(function(value){
         Promise.all(task);
    })
</script>    

normally, the ajax, in task01 should be executed first, and then why does ajax, in Promise.all () execute Promise.all () first and then ajax in task01

Mar.23,2021

normally, you should execute task [0] before task [1], because the functions in new Promise () are execute immediately, so the order of ajax execution is that task [0] precedes task [1] before task01.

The function of

Promise.all () is to call the callback function following the Promise.all method only if the state of task [0] and task [1] becomes fulfilled, or one of them becomes rejected,.

so

task01().then(function(value){
     Promise.all(task);
})

the function here is to execute the ajax, wait state in task01 and change it to fulfilled, execution Promise.all (task)

.
Menu