📜  制作一定长度的 id js - Javascript 代码示例

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

代码示例1
function makeID (length) { //Generates an id of  that never starts with 0
      length --; 
    const id = parseInt(Math.floor(Math.random() * (9 - 1) + 1) + "" + Math.floor(Math.random() * 10 ** length)); 
      return id;
}