ES6 String Literals vs. String Concatenation (v4)

Revision 4 of this benchmark created by Brandon on


Setup

var precalculatedIso = (new Date()).toISOString();

Test runner

Ready to run.

Testing in
TestOps/sec
ES6 with variable
var test = `<body>
  <article>
    <time datetime='${ precalculatedIso }'>${ precalculatedIso }</time>
  </article>
</body>`;
ready
String concatenation with variable
var test = "<body>"+
  "<article>"+
    "<time datetime='" + precalculatedIso +"'>"+ precalculatedIso +"</time>"+
  "</article>"+
"</body>";
ready
ES6 with function
var test = `<body>
  <article>
    <time datetime='${ (new Date()).toISOString() }'>${ (new Date()).toISOString() }</time>
  </article>
</body>`;
ready
String concatenation with function
var test = "<body>"+
  "<article>"+
    "<time datetime='" + (new Date()).toISOString() +"'>"+ (new Date()).toISOString() +"</time>"+
  "</article>"+
"</body>";
ready
String replace
var test = "<body><article><time datetime='${precalculatedIso}'>${precalculatedIso}</time></article></body>".replace(/\$\{precalculatedIso\}/g,precalculatedIso);
ready

Revisions

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