Make _.range coerce arguments to numbers.

Former-commit-id: 5408800fef0bc8a418c298a112049232b6d85e78
This commit is contained in:
John-David Dalton
2012-07-25 01:32:28 -07:00
parent 6d488b6a81
commit 0d7bdb6fa8
2 changed files with 64 additions and 33 deletions

View File

@@ -1695,9 +1695,11 @@
* // => []
*/
function range(start, end, step) {
step || (step = 1);
start = +start || 0;
step = +step || 1;
if (end == null) {
end = start || 0;
end = start;
start = 0;
}
// use `Array(length)` so V8 will avoid the slower "dictionary" mode