mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Avoid arguments object in _.random.
Former-commit-id: 24e54869ae03c0251f419c922f59f53f01b8fa35
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user