Test name | Executions per second |
---|---|
Ternary with Concat | 812205.2 Ops/sec |
Traditional If/Else with Concat | 791233.1 Ops/sec |
var cacheName ='';
componentsCfg = {};
componentsCfg.v = 1;
componentsCfg.h = 'asdf';
cacheName = (componentsCfg.v && componentsCfg.h) ? 'ch-' + componentsCfg.v + '-' + componentsCfg.h : 'ch';
if(componentsCfg.v && componentsCfg.h) {
cacheName = 'ch-' + componentsCfg.v + '-' + componentsCfg.h;
} else {
cacheName = 'ch';
}