Test name | Executions per second |
---|---|
Function calls | 3165074.5 Ops/sec |
Conditional operator | 3325719.5 Ops/sec |
var event = { foo: 'foo', bar: 'bar'}
var result1 = null
var result2 = null
function getName1(event) { return event.foo }
function getName2(event) { return event.foo + event.bar }
var flag1 = true
var flag2 = false
result1 = { name: getName1(event) }
result2 = { name: getName2(event) }
result1 = { name: flag1 ? event.foo : event.foo + event.bar }
result2 = { name: flag2 ? event.foo : event.foo + event.bar }