“Generador de código único JavaScript” Código de respuesta

ID aleatorio 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

Generador de código único JavaScript

let ID = (length = 6) => {
	// new Date() will return current time
  	// getTime() method returns the number of milliseconds* since the Unix Epoch.
	// -length to get last items on string
	return new Date().getTime().toString().slice(-length);
}
aoneahsan

Respuestas similares a “Generador de código único JavaScript”

Preguntas similares a “Generador de código único JavaScript”

Más respuestas relacionadas con “Generador de código único JavaScript” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código