Test name | Executions per second |
---|---|
Try/catch | 456388.6 Ops/sec |
Without try/catch | 386831.3 Ops/sec |
<div id="test"></div>
const n = Math.random()
try {
JSON.parse('{"name":"John", "age":31, "city":"New York"}');
} catch(e) {
console.log('error');
}
const n = Math.random()
if (n !== 0) {
JSON.parse('{"name":"John", "age":31, "city":"New York"}');
} else {
console.log('error')
}