Default Values

Benchmark published by System on

Description

Default parameters vs Logical OR vs Nullish Coalescing.

Setup

function withDefault(x = 10) { return x; }
function withOr(x) { return x || 10; }
function withNullish(x) { return x ?? 10; }

Test Runner

Initializing...

Testing in
Test CaseOps/sec
Default param
withDefault(undefined);
ready
Logical OR
withOr(undefined);
ready
Nullish Coalescing
withNullish(undefined);
ready

Revisions

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

Revision 1
publishedby Systemon