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);
