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?
I think you are mixing up objects and arrays. Objects have named keys, arrays have numeric keys. You can easily append to an array using
.push():However, for a configuration object as your variable name suggests this is not really useful. You should rather use meaningful names for your options, e.g.:
You can also store an array in your object: