Little-known Browser JavaScript APIs

crypto.randomUUID()

Generate UUIDs with browser native randomUUID API.

// returns 36b8f84d-df4e-4d49-b662-bcde71a8764f
self.crypto.randomUUID()

String.padStart()

Add padding to the beginning of the string. This is useful when you want to format hours and always show 2 digits.

let hours = 2
hours.toString().padStart(2, "0")
// returns 02

let hours = 12
hours.toString().padStart(2, "0")
// returns 12