Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
, where each x
is replaced with a random hexadecimal digit from 0 to f, and y
is replaced with a random hexadecimal digit from 8 to b.
There's also @LeverOne's approach using iteration, which is one byte shorter.
I was perusing the minified source of a website to see how they did something, came across this interesting way to create a GUID, and traced it back to here. I thought it was interestingly minified in the source I was looking at (with an insanely clever minifier!). Made me laugh when I saw that the original was golfed. 😆 A+ on the golfing, BTW! Clever minifier indeed--a clever human minifier. This was really fun to mentally chew on.