存储在数组中的变量变量称为==问题。 [英] Variable variables stored in an array and called == problem.
问题描述
我遗漏了一些基本的东西。
我有一个数组:
arr1 = [''one'',''两个'',''三''];
我有三个函数,分别命名为一,二,三。
是否有可能使用arr1 [0]();? (或类似的东西,因为那是
显然不是正确的方法。)
-
-Lost
删除要通过电子邮件回复的额外单词。不要给我发电子邮件。我是开玩笑的。不,我不是。
I am missing something fundamental here.
I have an array:
arr1 = [''one'', ''two'', ''three''];
I have three functions named one, two, and three.
Is it possible to use arr1[0]();? (Or something like it, since that is
obviously not the correct method.)
--
-Lost
Remove the extra words to reply by e-mail. Don''t e-mail me. I am
kidding. No I am not.
推荐答案
-Lost在27 mei 2007上写的comp.lang.javascript :
-Lost wrote on 27 mei 2007 in comp.lang.javascript:
我在这里缺少一些基本的东西。
我有一个数组:
arr1 = [''one'',''two'',''three''];
我有三个函数,分别为一,二,三。
是否可以使用arr1 [0]();? (或类似的东西,因为那是
显然不是正确的方法。)
I am missing something fundamental here.
I have an array:
arr1 = [''one'', ''two'', ''three''];
I have three functions named one, two, and three.
Is it possible to use arr1[0]();? (Or something like it, since that is
obviously not the correct method.)
< script type =''text / javascript ''>
var arr = [''one'',''two'',''three''];
函数一(){
alert('' - ONE - '');
};
window [arr [0]]();
< / script>
-
Evertjan。
荷兰。
(请将x''es更改为我的电子邮件地址中的点数)
<script type=''text/javascript''>
var arr = [''one'', ''two'', ''three''];
function one(){
alert(''-ONE-'');
};
window[arr[0]]();
</script>
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
5月27日, 7:52 pm,-Lost< maventheextrawo ... @ techie.comwrote:
On May 27, 7:52 pm, -Lost <maventheextrawo...@techie.comwrote:
我在这里缺少一些基本的东西。
我有一个数组:
arr1 = [''one'',''two'',''three''];
我有三个函数,分别是一个,两个和三个。
是否可以使用arr1 [0]();? (或类似的东西,因为那是
显然不是正确的方法。)
-
-Lost
删除要通过电子邮件回复的额外单词。不要给我发电子邮件。我是开玩笑的。不我不是。
I am missing something fundamental here.
I have an array:
arr1 = [''one'', ''two'', ''three''];
I have three functions named one, two, and three.
Is it possible to use arr1[0]();? (Or something like it, since that is
obviously not the correct method.)
--
-Lost
Remove the extra words to reply by e-mail. Don''t e-mail me. I am
kidding. No I am not.
如果这真的是你需要的,那么
eval(arr1 [0] +"()");
//未经测试
If that''s really what you need, then
eval( arr1[0] + "()" );
// not tested
Darko于2007年27日在comp.lang.javascript 上写道:
Darko wrote on 27 mei 2007 in comp.lang.javascript:
5月27日晚上7:52,-Lost< maventheextrawo ... @ techie.comwrote:
On May 27, 7:52 pm, -Lost <maventheextrawo...@techie.comwrote:
>我在这里缺少一些基本的东西。
我有一个阵列:
arr1 = [''one'',''two'', ''三'';
我有三个函数,分别为一,二,三。
是否可以使用arr1 [0]();? (或类似的东西,因为那显然不是正确的方法。)
-
-Lost
删除多余的单词通过电子邮件回复。不要给我发电子邮件。我在开玩笑。不我不是。
>I am missing something fundamental here.
I have an array:
arr1 = [''one'', ''two'', ''three''];
I have three functions named one, two, and three.
Is it possible to use arr1[0]();? (Or something like it, since that is
obviously not the correct method.)
--
-Lost
Remove the extra words to reply by e-mail. Don''t e-mail me. I am
kidding. No I am not.
如果这真的是你需要的,那么
eval(arr1 [0] +"()");
//未测试
If that''s really what you need, then
eval( arr1[0] + "()" );
// not tested
eval()是邪恶的,这里不需要,
看到我的其他帖子为了更好的解决方案。
-
Evertjan。
荷兰。
(请更改x'我的电子邮件地址中的点数。
eval() is evil and not necessary here,
see my other post for a better solution.
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
这篇关于存储在数组中的变量变量称为==问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!