A UUID is a 128-bit identifier written as 32 hex digits in five hyphen-separated groups. The point of it is that you can generate one anywhere, with no coordination, and be confident nobody else will ever generate the same value. That property is what makes it useful as a primary key, a correlation id, an idempotency key, or a filename.
Version 4 is the one people mean by default: 122 random bits, no structure, no information about when or where it was created. It is the right choice almost all of the time. The collision probability is small enough to ignore in practice, and because it carries no embedded data it leaks nothing about your system.
Version 7 is worth knowing about because it fixes a real problem with v4 as a database key. A v7 UUID starts with a millisecond timestamp, so values generated later sort after values generated earlier. Random v4 keys scatter inserts across a B-tree index, which fragments it and hurts write throughput on a large table; sequential v7 keys append instead, which is much friendlier to the index and gives you rough creation ordering for free. The trade is that a v7 id reveals when it was created.
Both versions here are generated with your browser's cryptographic random source, not Math.random, so the values are suitable for identifiers that must be unguessable as well as unique.