Script Preparation code:
AخA
 
var str = 'abc';
str = str.charAt(Math.floor(Math.random() * 3));
Tests:
  • Switch

    x
     
    const useSwitch = (str) => {
      switch (str) {
        case 'a': return 'A'; break
        case 'b': return 'B'; break
        case 'c': return 'C'; break
      }
    }
    console.log(useSwitch(str));
  • Object property

     
    const useObject = (str) => {
      let letters = {
        a: 'A',
        b: 'B',
        c: 'C'
      }
      return letters[str]
    }
    console.log(useObject(str));
  • Object with arrow funcion

     
    var arrow = {
      
      a: () => 'A',
      b: () => 'B',
      c: () => 'C'
      
    }
    console.log(arrow[str]());
  • Object with funcion (from the link in description)

     
    var objLiteral = {
      a: function() {
        console.log('A');
      },
      b: function() {
        console.log('B');
      },
      c: function() {
        console.log('C');
      }
    }
    objLiteral[str]();
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Switch
    Object property
    Object with arrow funcion
    Object with funcion (from the link in description)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 years ago)
Mozilla/5.0 (Linux; Android 9; SM-N9600) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36
Chrome Mobile 79 on Android
View result in a separate tab
Test name Executions per second
Switch 59416.1 Ops/sec
Object property 58909.7 Ops/sec
Object with arrow funcion 55503.1 Ops/sec
Object with funcion (from the link in description) 57313.0 Ops/sec