String concatenation (v95)

Revision 95 of this benchmark created on


Description

Different ways to concatenate strings together

Setup

var template = '<div class="className">{{keyName}}<div class="className">{{keyName}}</div><div class="className">{{keyName}}</div></div>';
    var key = 'keyName';
    var value = 'replacement';

Test runner

Ready to run.

Testing in
TestOps/sec
replace string
var foo = template.replace('{{' + key + '}}', value);
ready
replace regexp, non-global
var foo = template.replace(new RegExp('\{\{' + key + '\}\}'), value);
ready
replace regexp
var foo = template.replace(new RegExp('\{\{' + key + '\}\}', 'g'), value);
ready
split join
var foo = template.split('{{' + key + '}}').join(value);
ready

Revisions

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