var obj={x1:1,X2:2,X3:3};var i= 1,n=3;for(;i<=n;i++){ document.write(obj['x'+i]+"<br>");}这里显示的结果为什么是:1,undefined,undefined
Loop output of object attributes-PHP Chinese website Q&A-Loop output of object attributes-PHP Chinese website Q&A
Take a look around and learn.
var obj={x1:1,X2:2,X3:3};var i= 1,n=3;for(;i<=n;i++){ document.write(obj['x'+i]+"<br>");}
大小写问题 改成对应的小写x即可。
Loop output of object attributes-PHP Chinese website Q&A-Loop output of object attributes-PHP Chinese website Q&A
Take a look around and learn.
var obj={x1:1,X2:2,X3:3};
var i= 1,n=3;
for(;i<=n;i++){
document.write(obj['x'+i]+"<br>");
}
大小写问题 改成对应的小写x即可。