Read array values in a loop in JavaScript

前端 未结 8 2045
执笔经年
执笔经年 2021-02-14 06:49

I have an array in JavaScript that have defined these values:

var myStringArray = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\"];
8条回答
  •  北恋
    北恋 (楼主)
    2021-02-14 07:09

    function* employeeNames(){
        var empList =  ["1","2","3","4","5","6","7","8","9","10"];
    
        for(var i =0; i<=empList.length; i++){
            yield empList[i];
        }
    }
    
    var emp;
    emp = employeeNames();
    

    It uses a generator function...

提交回复
热议问题