javascript - Math.random() and .replace() cross-browser -
i wrote code generate 10 characters randomly. math.random() gives decimal tostring(36) , numbers replaced. math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); does have hint why firefox (47.0) , chrome (51) don't handle equally? chrome tests: math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); "spkcirhyzb" "gcqbrmulxe" "sallvbzqbk" "pcdcufhqet" "knfffqsytm" firefox tests: math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); "zxntpvn" "hebfyxlt" "zclj" "ormtqw" "cfbsnye" live version: for (var n = 0; n < 5; ++n) { console.log(math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10)); } update (string average): var test; var count = 0; (var n = 0; n < 1000; ++n) { test = math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); cou...