Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Windows
Desktop
9 months ago
Test name Executions per second
find 177601184.0 Ops/sec
for with break 142779072.0 Ops/sec
HTML Preparation code:
AخA
 
1
<div id='test'></div>
Tests:
  • find

     
    const arr = ['1', '2', '3'];
    let val = arr.find(node => node.id === '3');
  • for with break

     
    const arr = ['1', '2', '3'];
    let val;
    for(i=0; i<arr.length; i++){
      const value = arr[i];
      if (value === '3') {
        val = value;
        break;
       }
    }