Skip to main content

Command Palette

Search for a command to run...

I published JavaScript Guid Generator

Published
•2 min read•View as Markdown
I

Full-Stack Web Developer.

Hi. I published JavaScript Guid Generator on Github.

JavaScript Guid Generator

If you're interested in C#, maybe you know C# has built-in Guid class and its generator method. I can say, guid isn't random chars. Guid is designed to be unique. Which means, guid isn't random. This isn't my thought, also microsoft's employee wrote a post.

Guid Format

Guids are looks like this:

7abcc78e-eb7a-4ffa-52e1-7593212419f4 6d48e511-9724-4562-9770-57424ce7e631 b464bdc7-f0b6-4aab-cba2-71b48a067aac f9a691b5-5b62-4513-b927-70ba96301cf2 5fa7f00d-0a5e-478b-546c-6a72d3197fbd 6709eae5-fd5c-4655-5e1f-78eecb7bb0d4 c3fbf106-e9d5-41a1-b79b-5b8b8289713d

Usage

For example you'll use this class with a button click event. Our example should be like this:

var btn = document.querySelector("button");

btn.addEventListener("click", () => { console.log(Guid.NewGuid()) })

JavaScript Guid Generator on Github

I published this simple class on Github. Actually there are similar code snippets everywhere. But I published a class on Github as a repository.

You can see on Github: https://github.com/aligoren/Guid.JS

Live Example

If you want to see example I published a pen.

https://codepen.io/aligoren/pen/KyMqKW

Before this post I published post about Aurelia and Web API 2.

Thank you for reading. Leave a comment if you have a question.

6 views

More from this blog

Ali GOREN's Programming Blog

176 posts