Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133
Mac OS X 10.15.7
Desktop
22 days ago
Test name Executions per second
string enums 16989.6 Ops/sec
numeric enums 16853.5 Ops/sec
Tests:
  • string enums

    x
     
    const a = {
        one: 'one',
        two: 'two',
    };
    let c = 0;
    for (let i = 0; i < 100000; i++) {
        const v = i % 2 === 0 ? a.one : a.two;
        if (v === a.one) {
            c++;
        }
    }
  • numeric enums

     
    const a = {
        one: 1,
        two: 2,
    };
    let c = 0;
    for (let i = 0; i < 100000; i++) {
        const v = i % 2 === 0 ? a.one : a.two;
        if (v === a.one) {
            c++;
        }
    }