📜  如何从数组 js 中生成随机字符 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:22.559000             🧑  作者: Mango

代码示例2
function makeid() {
  var text = "";
  var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

  for (var i = 0; i < 5; i++)
    text += possible.charAt(Math.floor(Math.random() * possible.length));

  return text;
}

console.log(makeid());