Avatar ·

How to create GUID / UUID in JavaScript?

Hello everyone! I'm writing a small web application in pure JavaScript, and I need to generate unique identifiers for different entities (for example, for tasks in a to-do list or for records in local storage). I know that in other languages (Python, C#) there are built-in functions for creating GUID/UUID, but in JavaScript I haven't found anything similar. The problem is that I don't want to use simple counters like `let id = 0; id++`, because when the page is reloaded, the counter resets, and if the application works with multiple tabs or with a server, collisions may occur. I tried to write my own function based on `Math.random()`, but I read that it's not secure and doesn't guarantee uniqueness. Here's what I came up with: ```javascript function generateId() { return M