Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
Need help understanding how this JS code is generating UUID

I got this piece of code for generating UUID in case the browser doesn't support crypto.randomUUID.

I need help understanding how this works. A step by step process would be much appreciated. Would also like to know the official term that is used to define this kind of process.

var random_string = (
    Math.random().toString(16) +
    Math.random().toString(16) +
    Math.random().toString(16) +
    Math.random().toString(16) +
    Math.random().toString(16)
  ).replace(/0\./g, ""),
  random_y_bit = [8, 9, "a", "b"][~~(Math.random() * 4)],
  template_uuid = /.*(........)..(....)..(...)..(...)..(............).*/,
  replace_pattern = "$1-$2-4$3-" + random_y_bit + "$4-$5";

return random_string.replace(template_uuid, replace_pattern);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda