To create an array of object literals in a loop with JavaScript, we use the map
method.
For instance, we write
const arr = oFullResponse.results.map((obj) => ({
key: obj.label,
sortable: true,
resizeable: true,
}));
to call oFullResponse.results.map
with a callback that returns an object with the properties and return an array with the objects returned by the map
callback.