If I push objects created on the fly, including another internal array of objects, to an array, how can I add objects only to a specific object's array. Using Reviews for example:
reviews.push({ 'reviewer' : 'John',
'review' : 'This movie was the greatest',
'comments' : { 'commenter' : 'Dave',
'comment' : 'The review by John was too short'}
});
'comments' being the internal array of objects.
If at a later stage I want to add objects only to a specific object's 'comments' by it's parents name/ID, is it possible? And if so how would I go about doing it?
Using the example, If there is only 1 review with multiple comments, and the comments come at a later stage, how can I add new comments to the 'comments' array within the review object?
I am guessing I would need to have a review ID to stop duplicates etc, but that aside I'm not even sure syntactically how to do it or if it's even possible.
Thanks in advance.