Conditional assignment (v2)

Revision 2 of this benchmark created on


Setup


Test runner

Ready to run.

Testing in
TestOps/sec
Multiple conditionals
const cond = true
const foo = cond ? 'a' : 'b'
const bar = cond ? 'c' : 'd'
const baz = cond ? 'x' : 'y'
ready
Conditional array assignment
const cond = true
const [foo, bar, baz] = cond ? ['a', 'c', 'x'] : ['b', 'd', 'y']
ready
Conditional object assignment
const cond = true
const {foo, bar, baz} = cond ? {foo: 'a', bar: 'c', baz: 'x'} : {foo: 'b', bar: 'd', baz: 'y'}
ready

Revisions

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