<script>
var obj = {};
for (var i = 0;i < 10;i++){
obj['a'+i]=i * 2;
}
console.log(obj);
</script>
image.png
<script>
var obj = {};
for (var i = 0;i < 10;i++){
obj['a'+i]=i * 2;
}
console.log(obj);
</script>
image.png
本文标题:javascript动态生成对象
本文链接:https://www.haomeiwen.com/subject/igssaftx.html
网友评论