What is the best practice for filtering or reducing an object? I would do it through a for-loop and create a new array, but understand that you can do it somehow through the filter property in JavaScript?
var myObject = [
{dimensions: [451, 255], margins: [0, 2, 0, 29]},
{dimensions: [222, 390], margins: [0, 5, 0, 37]},
{dimensions: [333, 390], margins: [0, 8, 0, 37]}
];
I would like to separately separate the sizes, properties and fields of the second and fourth properties in the array:
var dimension = [ 451, 222, 333 ];
var margins = [ 2, 29, 5, 37, 8, 37 ];
Also, if I filter an object and update these variables, is there a way to map them? Or I should have it as shown below, after which:
var dimension = [ a: 451, b: 222, c: 333];
var margins = [ a: [2, 29], b : [5, 37], c: [8, 37] ];