Script Preparation code:
AخA
 
function genRandomString(length) {
   var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
   var charLength = chars.length;
   var result = '';
   for ( var i = 0; i < length; i++ ) {
      result += chars.charAt(Math.floor(Math.random() * charLength));
   }
   return result;
}
Tests:
  • for

     
    let dict = {}
    let exp = 'nice'
    for (let i=0;i<20;i++){
     dict[genRandomString(20)]='test'; 
    }
    dict[exp] = 'what';
    function findsmthg() {
      for (const t in Object.keys(dict)) {
        if(t.toLowerCase() === exp.toLowerCase()) {
          return true;
        }
      }
      return false;
    }
    findsmthg();
  • find

     
    let dict = {}
    let exp = 'nice'
    for (let i=0;i<20;i++){
     dict[genRandomString(20)]='test'; 
    }
    dict[exp] = 'what';
    function validate(val) {
      return val.toLowerCase() === exp.toLowerCase();
    }
    function findsmthg() {
      return !!Object.keys(dict).find(validate);
    }
    findsmthg();
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for
    find

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.62
Chrome 103 on Windows
View result in a separate tab
Test name Executions per second
for 2817.2 Ops/sec
find 3098.1 Ops/sec