Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Chrome 100
Linux
Desktop
2 years ago
Test name Executions per second
Try/catch 456388.6 Ops/sec
Without try/catch 386831.3 Ops/sec
HTML Preparation code:
AخA
 
1
<div id="test"></div>
Tests:
  • Try/catch

     
    const n = Math.random()
    try {
      JSON.parse('{"name":"John", "age":31, "city":"New York"}');
    } catch(e) {
      console.log('error');
    }
  • Without try/catch

    x
     
    const n = Math.random()
    if (n !== 0) {
      JSON.parse('{"name":"John", "age":31, "city":"New York"}');
    } else {
      console.log('error')
    }