Tests:
  • 12

    x
     
    let params = {a: undefined, b: null, c: false, d: 'a', e: 1};
    Object.keys(params).reduce((urlParams, key) => {
                if (params[key] === undefined) return urlParams;
                return `${urlParams}${key}=${encodeURIComponent(String(params[key]))}&`;
            }, '?').slice(0, -1);
            
            
  • 13

     
    let params = {a: undefined, b: null, c: false, d: 'a', e: 1};
    Object.keys(params).reduce((urlParams, key) => {
                if (params[key] === undefined) return urlParams;
                return `${urlParams}${urlParams !== '' ? '&' : '?'}${key}=${encodeURIComponent(String(params[key]))}`;
            }, '');
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    12
    13

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
Chrome 94 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
12 334211.2 Ops/sec
13 337223.6 Ops/sec