Why is using a generator function slower than filling and iterating an array in this example?

后端 未结 4 1490
温柔的废话
温柔的废话 2021-02-12 21:26

A Tale of Two Functions

I have one function that fills an array up to a specified value:

function getNumberArray(maxValue) {
    const a         


        
4条回答
  •  别那么骄傲
    2021-02-12 21:36

    FYI this question is ancient in internet terms and generators have caught up (at least when tested in Chrome) https://jsperf.com/generator-vs-loops1

提交回复
热议问题