compare

Benchmark created on


Setup

const locale = 'th'
const item = {
	name_th : 'name_th ',
	name_en: 'name_en'
	
}

Test runner

Ready to run.

Testing in
TestOps/sec
com1
for (let index = 0; index < 100; index++) {
const text = locale === 'th' ? item.name_th : item.name_en
}
ready
com2
const isTh = locale === 'th'

for (let index = 0; index < 100; index++) {
const text = isTh ? item.name_th : item.name_en
}
ready
com3
const key = locale.value === 'th' ? 'name_th' : 'name_en'

for (let index = 0; index < 100; index++) {
const text = item[key]
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.