标签:
1.用eval,例子:
1
2
3
4
5
6
7
|
<script> var Thread_num=5; for ( var i=1;i<=Thread_num;i++){ eval( "var set_" + i + "=" + i); } alert(set_5); </script> |
2.方法1占内存,建议用数组代替
1
2
3
4
5
6
7
|
<script> var Thread_num=5; var arr=[]; for ( var i=1;i<=Thread_num;i++){ arr[i] = i; } </script> |
标签:
原文地址:http://www.cnblogs.com/webenh/p/5671601.html