Need to get the value of a variable which is sent as a string?

I'm sending a string as parameter to a function, but i already have a global variable in that name, i want to get the value of that variable but its sending as undefined.. My example code i have a array as reg[0][0],reg[0][1],reg[1][0],reg[1][0],reg[2][0],reg[2][1] and i have some global variables as tick1, tick2, tick3... it will either have the values as 0,1 or 2 and in a function i called calc_score(id) //id will return as either tick1,tick2,tick3 { alert(eval("reg[id][1]")); // it should return the value of reg[0][1] if id is 0 } But its not working. The id wont be a numeral it will be string .. So how can i do this?

以上就是Need to get the value of a variable which is sent as a string?的详细内容,更多请关注web前端其它相关文章!

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

评论 抢沙发

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

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

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏