conditional properties

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
conditional spread
let condition = true;
const obj = {
	...(condition && {dogs: 'woof'}), 
	...(!condition && {cats: 'meow'})
}
ready
ternary
let condition = true;
const obj = condition ? {dogs: 'woof'} : {cats: 'meow'};
ready
if
let condition = true;
let obj = {cats: 'meow'};
if (condition) {
	obj = {dogs: 'woof'}
}
ready

Revisions

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