This content originally appeared on Go Make Things and was authored by Go Make Things
Today, I wanted to quick show you how to generate a UUID (University Unique Identifier) using the vanilla JS crypto.randomUUID()
method.
There’s really not much to show. You run it, and it generates a unique ID.
// returns something like this:
// "f116fb21-79f2-4ec0-8a81-85b5837ea0f3"
let id = crypto.randomUUID();
Because it’s a cryptographically secure identifier, it requires an SSL certificate to run. However, exceptions are made for localhost://
and file://
for testing.
⏰ Last Chance! A new session of the Vanilla JS Academy started this week, but it's not too late to join. Sign up today and get 25% off registration.
This content originally appeared on Go Make Things and was authored by Go Make Things
Go Make Things | Sciencx (2022-07-18T14:30:00+00:00) Generating a UUID (Universally Unique Identifier) with vanilla JS. Retrieved from https://www.scien.cx/2022/07/18/generating-a-uuid-universally-unique-identifier-with-vanilla-js/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.