Why is an extra array of arrays being created inside an array of JSON objects in javascript
I am adding JSON objects to an array using the push command. After adding this array, only two JSON objects are displayed. Then I add the whole array to another array containing 7 other arrays. Finally, when I access the array of JSON objects, it shows two JSON objects and one additional array containing the same objects and array. Here I have attached the code and result of the result. How can I solve this?
prevArrhythBeats.push(
{
x: annotationPacket[k].timestamp,
title: annotationPacket[k].annotBeat.a_type,
text: annotationPacket[k].annotBeat.a_desc
}
);
dataFactory.setPrevData(prevChOne, prevChTwo, prevGrid, prevLeadChange, prevMotion, prevArrhythBeats)
dataFactory.setPrevData = function (cOne, cTwo, grid, lead, mot, beat) {
prevData.push(cOne);
prevData.push(cTwo);
prevData.push(grid);
prevData.push(lead);
prevData.push(mot);
prevData.push(beat);
}
+3
source to share