There is a condition when I need to convert an array of objects to an array of arrays.
Example: -
arrayTest = arrayTest[10 objects inside this array]
one object has several properties that I add dynamically, so I don’t know the name of the property.
Now I want to convert this array of objects to an array of arrays.
PS If I know the property name of an object, then I can convert it. But I want to do it dynamically.
Example (if I know the name of the property (firstName and lastName are the name of the property))
var outputData = [];
for(var i = 0; i < inputData.length; i++) {
var input = inputData[i];
outputData.push([input.firstName, input.lastName]);
}
source
share