Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.142 Safari/537.36
Chrome 81
Windows
Desktop
4 years ago
Test name Executions per second
+= 11610.1 Ops/sec
array joining 13603.0 Ops/sec
template strings 11610.1 Ops/sec
Script Preparation code:
AخA
 
var str, strarr
var chars = 'abcdefghijklmnoprstuwxyz'
Tests:
  • +=

     
    str = ''
    while (str.length < 100) str += chars[ Math.floor( Math.random() * chars.length ) ]
  • array joining

     
    strarr = []
    while (strarr.length < 100) strarr.push(chars[ Math.floor( Math.random() * chars.length ) ])
    str = strarr.join('')
  • template strings

     
    str = ''
    while (str.length < 100) str = `${str}${chars[ Math.floor( Math.random() * chars.length ) ]}`