This question already has an answer here:
Given a JavaScript object, how can I convert it into an array of objects (each with key, value)?
Example:
var data = { firstName: 'John', lastName: 'Doe', email: 'john.doe@gmail.com' }
resulting like:
[
{ key: 'firstName', value: 'John' },
{ key: 'lastName', value: 'Doe' },
{ key: 'email', value: 'john.doe@gmail.com' }
]
The previous answer lead me to think there is a better way...
or in ES6 using arrow functions:
You can just iterate over the object's properties and create a new object for each of them.