Reference Javascript Array (JSON Format) with unknown array key

How would you reference a value in a Javascript object without the key? So, given the object: var JSONdata= [ {"index":"1","var1":1,"var2":2}, {"index":"2","var1":3,"var2":2}, {"index":"3","var1":3,"var2":1}, {"index":"4","var1":2,"var2":1}, {"index":"5","var1":1,"var2":3}, ]; Say I want to reference the values of var1 and var2 in a loop, but the names "var1" and "var2" change and the number of variables also changes. So in Pseudocode: while ( i < JSONdata.length ) { for (j = 1 to Num_variables) { Give me the value for varN next j } i++ } Thanks
Do you want to exclude the index property but include all other properties of each object?

以上就是Reference Javascript Array (JSON Format) with unknown array key的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准