javascript怎么实现range函数

2024-11-25 08:27:55
推荐回答(2个)
回答1:

range = (start,end,step)=>Array.from({length:Math.ceil((end-start)/step.toFixed(2))},(e,i)=>start+i*step)

回答2:

let range = (start, end) => new Array(end - start).fill(start).map((el, i) => start + i);