JSFiddle - React, Tailwind, and code Playground

by Viet27th

JavaScript

const aarray = [...Array(100).keys()];
const barray = [...Array(100).keys()];

/* const alength = barray.length - 1;
const a = () => {
  return new Promise((resolve, reject) => {
    for (const [index, x] of aarray.entries()) {
      console.log("--Aaray", x);
      if (index === alength) {
        resolve(true);
      }
    }
  })
};

const blength = barray.length - 1;
const b = () => {
  return new Promise((resolve, reject) => {
    for (const [index, x] of barray.entries()) {
      console.log("--Baray", x);
      if (index === blength) {
        resolve(true);
      }
    }
  })
};

const test = async () => {
console.time("test_timer");
  const data = await Promise.all([b(), a()]);
  console.log("++++++", data);
  
 console.timeEnd("test_timer");
  
  return data;
}
test(); */



console.time("test_timer");
     for (const x of aarray) {
      console.log("--Aaray", x);
    }
     for (const x of barray) {
      console.log("--Baray", x);
    }
  
console.timeEnd("test_timer");