📅  最后修改于: 2022-03-11 15:03:24.503000             🧑  作者: Mango
function range(min, max) {
if (max === undefined && min !== undefined) {
return [...Array(min+1).keys()];
} else if (min !== undefined) {
return [...Array(max-min+1).keys()].map(elm => elm+min);
} else {
return;
}
}
range(5);// => [ 0, 1, 2, 3, 4, 5 ]
range(5,10);// => [ 5, 6, 7, 8, 9, 10 ]