Run details:
Mozilla/5.0 (Linux; Android 10; Redmi Note 9 Pro Max) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36
Chrome Mobile 85
Android
Mobile
4 years ago
Test name Executions per second
toString 247468.2 Ops/sec
JSON.stringify 217380.8 Ops/sec
template-literals 243924.3 Ops/sec
Script Preparation code:
AخA
 
function moreData(arr, left) {
  if(left === 0) return arr;
  else {
    arr.push(Math.floor(Math.random() * 256));
    return moreData(arr, left - 1);
  }
}
function makeTestData() { return moreData([], 4); }
Tests:
  • toString

     
    makeTestData().toString()
  • JSON.stringify

     
    JSON.stringify(makeTestData());
  • template-literals

     
    (`${makeTestData()}`);