Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15
Safari 14
Mac OS X 10.15.6
Desktop
4 years ago
Test name Executions per second
Nullish coalescing (??) 1221229.6 Ops/sec
Logical OR (||) 1225771.0 Ops/sec
Nullish coalescing (??) [short-circuit] 119122384.0 Ops/sec
Logical OR (||) [short-circuit] 143215168.0 Ops/sec
Tests:
  • Nullish coalescing (??)

    AخA
     
    let x = null ?? undefined ?? null ?? undefined ?? null ?? undefined ?? null ?? undefined ?? null ?? undefined ?? 1;
  • Logical OR (||)

     
    let x = null || undefined || null || undefined || null || undefined || null || undefined || null || undefined || 1;
  • Nullish coalescing (??) [short-circuit]

     
    let x = 1 ?? undefined ?? null ?? undefined ?? null ?? undefined ?? null ?? undefined ?? null ?? undefined ?? 1;
  • Logical OR (||) [short-circuit]

     
    let x = 1 || undefined || null || undefined || null || undefined || null || undefined || null || undefined || 1;