Declare variables programmatically?

前端 未结 3 918
醉梦人生
醉梦人生 2020-12-11 23:59

I am trying to create a bunch of variables like this:

function l(){
    var a1 = 2,
        a2 = 4,
        a3 = 6,
        a4 = 8,
          .
          .
          


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 00:25

    Don't do this. Do. Not. Do. This. Use an array.


    Given the trouble you're having creating them programmatically, how do you think you'd refer to them programmatically?

提交回复
热议问题