Wudang
BOFH
I had to read a bit as javascript is not one of my core languages. Since 2015 the main browsers which actually provide the implementation of the ECMAscript standard have agreed on xorshift128+. See https://johnkavanagh.co.uk/writing/javascripts-math-random/
And still it's a balance between randomness and performance.
The actual random function from chromium source code at https://source.chromium.org/
And still it's a balance between randomness and performance.
THE WRAP-UP
Fundamentally, any 'random' number that is generated programmatically actually is not random at all; any method used to generate these random numbers will eventually reveal repetition or patterns in the values they return.
At the end of the day, however, programming languages (and especially those for the web) need to be optimised for speed and performance above absolute randomisation. None of our web languages - at least for right now - use TRNGs and are truly random. However, our newer PRNGs are pretty good at what they do, and they’re pretty quick too. A comfortable middle-ground.
The actual random function from chromium source code at https://source.chromium.org/
// Static and exposed for external use.
static inline void XorShift128(uint64_t* state0, uint64_t* state1) {
uint64_t s1 = *state0;
uint64_t s0 = *state1;
*state0 = s0;
s1 ^= s1 << 23;
s1 ^= s1 >> 17;
s1 ^= s0;
s1 ^= s0 >> 26;
*state1 = s1;
}
