Avoid arguments object in _.random.

Former-commit-id: 24e54869ae03c0251f419c922f59f53f01b8fa35
This commit is contained in:
John-David Dalton
2012-08-31 18:03:10 -07:00
parent ce5ae1dfdd
commit 910804ecd1
2 changed files with 13 additions and 13 deletions

View File

@@ -3837,15 +3837,15 @@
* // => an integer between 0 and less than 1
*/
function random(min, max) {
if (!arguments.length) {
if (min == null && max == null) {
return nativeRandom();
}
min || (min = 0);
if (!max) {
min = +min || 0;
if (max == null) {
max = min;
min = 0;
}
return min + nativeFloor(nativeRandom() * (max - min + 1));
return min + nativeFloor(nativeRandom() * ((+max || 0) - min + 1));
}
/**