I would like to know when, in a browser environment Javascripts math.random method is seeded.
Is it:
A) When computer is switched on
B) When the browser is launched for the first time on a session
C) Each time the browser is launched
D) When the page with JS code containing math.random is opened for the first time
E) Each time that the page containing math.random is opened
F) When math.random() method is called for the first time
G) Others
From ECMAScript :
Returns a Number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy.
So, it depends on the browser.
As it doesn't make any practical difference (as long as it isn't seeded while your pages run) because the seed is itself kindof random (usually based on the timestamp of seeding time), browser documentations are sparse but here's what Internet Explorer's one says :
The random number generator is seeded automatically when JavaScript is first loaded.
As most other strategies would induce potential errors, I think you can assume there won't be any new seeding between the first call to Math.random and the browser closing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With