Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 OPR/102.0.0.0
Opera 102
Windows
Desktop
one year ago
Test name Executions per second
String concatenation (from Uint8Array) 97165.8 Ops/sec
Array map join 586573.6 Ops/sec
String concatenation (from Uint8Array converted to Array) 600025.1 Ops/sec
Script Preparation code:
AخA
 
var text = '鉴于对人类家庭所有成员的固有尊严及其平等的和不移的权利的承认,乃是世界自由、正义与和平的基础';
var uint8Array = new TextEncoder().encode(text);
Tests:
  • String concatenation (from Uint8Array)

     
    let byteStr = '';
    uint8Array.forEach(i => { byteStr += String.fromCharCode(i); });
  • Array map join

     
    let byteStr = new Array(uint8Array).map(i => String.fromCharCode(i)).join('');
  • String concatenation (from Uint8Array converted to Array)

     
    let byteStr = '';
    new Array(uint8Array).forEach(i => { byteStr += String.fromCharCode(i); });