javascript / jquery - creating an object in a particular format from a loop

巧了我就是萌 提交于 2019-12-06 21:18:28

Is this what you meant?:

var repo = [];

for (childIndex in scenes[sceneID].children) {  
    childSceneID = scenes[sceneID].children[childIndex];
    childScene = scenes[childSceneID];
    repo.push({"name": childScene});
}

var theobj = { "repo": repo };

I just put this here

var repo = new Object();
var table = new Object();
repo["repo"] = table;
table["name1"] = "resque";
table["name1"] = "hub";
table["name1"] = "rip";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!