gpt4 book ai didi

javascript - 如何在 Javascript 中使用字符串作为变量名?

转载 作者:搜寻专家 更新时间:2023-11-01 04:43:50 25 4
gpt4 key购买 nike

<分区>

Possible Duplicates:
Is there a way to access a javascript variable using a string that contains the name of the variable?
JavaScript: Get local variable dynamicly by name string

一个简单的代码来说明我的问题-

var chat_1 = "one";

var chat_2 = "two";

var id = "1";

var new = ?? variabalize( 'chat_' + id )

我希望为变量 new 分配变量的值 - chat_1,即“一”

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com