Javascript – How to add javascript object to another object in dynamic

addjavascriptobject

Suppose I have several javascript object

{"type":"gotopage","target":"undefined"}
{"type":"press","target":"a"}
{"type":"rotate","target":"long"}

How can I add this objects to another object like

config={}

I know how to if each inserted object have a id I can added as:

config["id"]={}

But in this case how can I add objects without id?

Best Solution

var obj1 = {"type":"gotopage","target":"undefined"};

var config = {};
config.obj1 = obj1;

You can always add them later.

var obj1 = {"type":"gotopage","target":"undefined"};

var config = {};
config.obj1 = obj1;

var obj2 = {"key":"data"};
config.obj2 = obj2;