Class array building

Benchmark created by Guillaume VanderEst on


Setup

const availableProtocolIds = ["internet", "something else"];

Test runner

Ready to run.

Testing in
TestOps/sec
Short-form
const connectionQuestionTypeClasses = ['question'].concat(availableProtocolIds.length < 2 ? ['disabled'] : []);
ready
Long-form
const connectionQuestionTypePreventsSelecting = availableProtocolIds.length <= 1;
const connectionQuestionTypeClasses = ['question'];
if (connectionQuestionTypePreventsSelecting) {
    connectionQuestionTypeClasses.push('disabled');
}
ready
Long-form with only less-than
const connectionQuestionTypePreventsSelecting = availableProtocolIds.length < 2;
const connectionQuestionTypeClasses = ['question'];
if (connectionQuestionTypePreventsSelecting) {
    connectionQuestionTypeClasses.push('disabled');
}
ready

Revisions

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

  • Revision 1: published by Guillaume VanderEst on