生成随机

1.随机生成汉字

function getRandomChineseWord() {
        var _rsl = ''
        var _randomUniCode = Math.floor(Math.random() * (40870 - 19968) + 19968).toString(16)
        eval('_rsl=' + '"\\u' + _randomUniCode + '"')
        return _rsl
      }

2.随机生成数字

Math.floor(Math.random()*89+10)  + msg.toString() + Math.floor(Math.random() * (08704545 - 11) + 1000)

 随机俩位数 + 数字转换成字符串 + 随机数字生成(位数不稳定)

.substr(2,1)

通过字符串截取得到中间那个变量msg

posted @ 2021-09-11 18:11  青眼魔术  阅读(48)  评论(0编辑  收藏  举报