Run details:
Mozilla/5.0 (Android 11; Mobile; rv:109.0) Gecko/111.0 Firefox/111.0
Firefox Mobile 111
Android
Mobile
one year ago
Test name Executions per second
using plus operator 13181872.0 Ops/sec
using concat function 208549.9 Ops/sec
using template literals 2714121.2 Ops/sec
Script Preparation code:
AخA
 
var name = "name";
var id = "id";
Tests:
  • using plus operator

     
    for (let i = 0; i < 80; ++i) {
      let result = id + ": 1, " + name + ": someItem";
    }
  • using concat function

     
    for (let i = 0; i < 80; ++i) {
      let result = "".concat(id, ": 1, ", name, ": someItem");
    }
  • using template literals

     
    for (let i = 0; i < 80; ++i) {
      let result = `${id}: 1, ${name}: someItem`;
    }