d

Benchmark created on


Setup


     let starArray: [
        {
          id: 1,
          colorActive: false,
        },
        {
          id: 2,
          colorActive: false,
        },
        {
          id: 3,
          colorActive: false,
        },
        {
          id: 4,
          colorActive: false,
        },
        {
          id: 5,
          colorActive: false,
        },
      ]
 

Test runner

Ready to run.

Testing in
TestOps/sec
d2


      


        starArray.forEach((item, idx) => {
         if (item.id <= num) {
           starArray[idx].colorActive = true;
         } else {
           starArray[idx].colorActive = false;
        }
       });
      
ready
d3
 

 


      starArray = starArray.map((item) => ({
        ...item,
        colorActive: item.id <= num,
      }));
      
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.