
Variable Definition 2.1 ( var v = r & 0x3 | 0x8): This could be rewritten with a simple if/else-statement.
UUID GENERATOR JAVASCRIPT CODE

By using the bitwise OR-operator with zero ( | 0), we basically floor the result, since the number ist cast to an integer.

By multipling the value with 16, the result is between 0 and 16.Math.random() is a function that returns a value between 0 and 1.Variable Definition 1: ( r = Math.random() * 16 | 0 ): This line defines 2 variables, namely r and v. However, let's focus especially on your requested line and let me try to explain it step by step. For an updated solution of your function check out: and for more details on UUIDS: Additonally it does not stick to the RFC standards for UUIDS. However, its readability is very bad, in exchange for very short code.

It is true that your method generates a more or less random string which could be used as a uuid.
