I have an object similar to the sample object below.
var obj = {
id : "",
entries: [
{
url : "some url",
response : {a response object}
},
{
url : "another url",
response : {a response object}
}
]
};
In the above object I have an entries
element which is an array of object. Each object inside entries
element will have a 'url' property and a 'response' property which is an object.
In the object there can be missing response property in entries. In such instance, I have a default response object in a variable 'tempObj' and I assign this tempObj to the 'entries' element.
var tempObj = {
status : 200
statusText : "Success"
};
obj.entries[1]["response"] = tempObj;
The problem is when there are multiple response elements missing in obj
it adds a response element correctly for the first missing entries
, but for the second entries
it adds a reference to the first element added.
I need to add the exact value in the second element as well. How can I do this?
This is in nodejs application (not client side javascript).