例1:循环赋值 a1=1,a2=2,a3=3,a4=4...a100=100
for (var i = 0; i < count; i++) {
eval(‘a‘+j+ ‘="‘+ (i+1) + ‘"‘);
};
例2:循环赋值 aa=1,ab=2,ac=3,ad=4...az=26;
for (var i = 0; i < count; i++) {
eval( ‘a‘+String.fromCharCode(97+i)+ ‘="‘+ (i+1) + ‘"‘ );
};
String.fromCharCode(97+i)代表从小写a开始
String.fromCharCode(65+i)代表从大写a开始
时间: 2024-10-28 11:23:33