crypto property in the Web API.
crypto.randomUUID() you'll generate a string containing a randomly generated, 36 character long v4 UUID that can be used in multiple different contexts.
Personally I've used UUID's for components in a design system where I needed a uniquely labelled ID attribute on a HTML element for accessibility reasons. For instance
label elements referring to inputs, but also
aria-describedby to establish a relationship between elements or groups and the text that describes them.