“ID acak JS” Kode Jawaban

ID acak JS

var ID = function () {
  // Math.random should be unique because of its seeding algorithm.
  // Convert it to base 36 (numbers + letters), and grab the first 9 characters
  // after the decimal.
  return '_' + Math.random().toString(36).substr(2, 9);
};
Diz Andriana

ID acak JS

Math.random().toString(36).slice(2);
Dotch

Hasilkan JavaScript ID acak

 const makeid = (length) =>  {
        var result           = '';
        var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        var charactersLength = characters.length;
        for ( var i = 0; i < length; i++ ) {
          result += characters.charAt(Math.floor(Math.random() * 
     charactersLength));
       }
       return result;
    }
Sid Potti

JavaScript generator id acak

function uid() {
 let a = new Uint32Array(3);
 window.crypto.getRandomValues(a);
 return (performance.now().toString(36)+Array.from(a).map(A => A.toString(36)).join("")).replace(/\./g,"");
};
Josh Chua

Jawaban yang mirip dengan “ID acak JS”

Pertanyaan yang mirip dengan “ID acak JS”

Lebih banyak jawaban terkait untuk “ID acak JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya