利用Generator函数和for...of循环,实现有限的斐波那契数列数组
function* fibonaqi(){ let [pre,cur] = [1,1]; for(;;){ [pre,cur] = [cur,cur+pre]; yield cur; }}let arr=[1,1];for(let n of fibonaqi()){ if(n >1000){ break; } arr.push(n)}console.log(arr)// [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,