Tests:
  • Using an object

    x
     
    const nonUnique = ['one', 'two', 'three', 'three', 'four', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
    const unique = Object.keys(nonUnique.reduce((acc, item) => {
      if (!acc[item]) {
        acc[item] = true
      };
      return acc;
    }, {}));
  • Using a Set

     
    const nonUnique = ['one', 'two', 'three', 'three', 'four', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
    const unique = Array.from(new Set(nonUnique));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Using an object
    Using a Set

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 18 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0
Chrome 134 on Windows
View result in a separate tab
Test name Executions per second
Using an object 3243160.8 Ops/sec
Using a Set 3800777.0 Ops/sec