I have below code
var obj = [];
var statuses = [];
var time ='';
statuses array has some values like
statuses[0] = [1]
statuses[1] = [0]
statuses[2] = [1]
statuses[3] = [1]
Now i want to push these values in obj array such that when i do obj[0].length it should come to 5
If i do obj.push(([time, statuses])) it gives length as 2
When i do obj.push(([time, statuses[0],statuses[1],statuses[2],statuses[3]]));
then i am getting value of obj[0].length as 5
I dont want to hardcode the values like statuses[0],[1] in obj.push as i am not sure how many values will be present in statuses array in future.
Ofcourse my status array will grow depending upon the values i receive from backend. So my obj[0].length should be number of objects in status array + time obj. Eg: if statuses has 8 values then my final obj[0].length should come to 9
I have tried using concat function but their is no luck.
Could anyone please help me out with how can I achieve this dynamically?
objarray in following order:time,statuses[0],statuses[1], ... ? Right?objit will be like thisobj [ time, status [ 1, 2, 3, ] ]