Null-guard vs null-greater-than comparison

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
null guard with null
const a = null
if(a != null && a.length > 3) {}
ready
null guard without null
const a = []
if(a != null && a.length > 3) {}
ready
null comparison without null
const a = []
if(a?.length > 3) {}
ready
null comparison with null
const a = null
if(a?.length > 3) {}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.