Split an array of objects into separate arrays
Posted: 11 Nov 2020, 11:27
I have an array of objects, and for plotting a graph I need to split it into 3 different arrays. How to do it using JS?
I need to get such arrays
What is the best way to accomplish this in JavaScript?
Code: Select all
const dataOverview = [{
id: 1,
series1: 31,
series2: 11,
timestamp: "2018-09-19T00:00:00.000Z"
},
{
id: 2,
series1: 40,
series2: 32,
timestamp: "2018-09-19T03:30:00.000Z"
},
{
id: 3,
series1: 28,
series2: 45,
timestamp: "2018-09-19T06:30:00.000Z"
}
];
Code: Select all
var series1 = [];
var series2 = [];
var timeStamp = [];