Reputation: 421
What changes adding the parameter in Math.random()
?
For example:
Math.random() == Math.random(1234)
Upvotes: 8
Views: 19398
Reputation: 147533
Read the specification:
15.8.2.14 random ( )
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. This function takes no arguments.
Upvotes: 9
Reputation: 178422
No official parameters. Have a look here: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/random
The confusion is understandable. Several sites have a seed in the function since it came from C / Java. More information about this ignored parameter here: Math.random() - Not random
If you want a better random number get one from here http://www.random.org/clients/http/ - you will need to wrap it in some server based client - see here for more information Cross domain ajax request from javascript file without help of server side code
UPDATE: Emailed the creator of random.org - he replied he is working on a jsonp implementation...
Upvotes: 4
Reputation: 22708
Math.random
doesn't take params.
If you want to generate a random number between 2 intervals (a and b) you can use the formula:
math.random()*(b-a)+a
Upvotes: 13
Reputation: 13445
Nothing. There is no seed for Math.random
in Javascript. Anything inside the function call will just be dropped.
Upvotes: 5
Reputation: 4536
It doesn't - Math.random()
doesn't take any parameters... :)
Upvotes: 2