Q:

Javascript - Best/fastest way to add element to query result with fixed value

I have a node.js mysql query: 
connection.query("SELECT id AS id, name AS label, status AS status from table;", function(err, rows) {
    ...
});

The result I'm getting back locks like this:
console.log(getBody)
[ { id: '1',
   label: 'Name 01',
   status: 'ACTIVE' },
 { id: '2',
   label: 'Name 02',
   status: 'INACTIVE' },
 { id: '3',
   label: 'Name 03',
   status: 'ACTIVE' },
 { id: '4',
   label: 'Name 04',
   status: 'ACTIVE' }];

To further cosume the result ... I need an additional paremeter 'type' with with a fixed value in the array. So result should look like this:       
[ { id: '1',
   label: 'Name 01',
   status: 'ACTIVE',
   type: 'ABC' },
 { id: '2',
   label: 'Name 02',
   status: 'INACTIVE',
   type: 'ABC' },
 { id: '3',
   label: 'Name 03',
   status: 'ACTIVE',
   type: 'ABC' },
 { id: '4',
   label: 'Name 04',
   status: 'ACTIVE',
   type: 'ABC' }];       

What's the fastest/best way to do this? Looping over the array? How should it look like?       

A:

Use the map method:
const newArray = array1.map(element => element = {...element, ...{type: 'ABC'}});
console.log(array1); // array1 won't be changed
console.log(newArray);

Or forEach, this will modify your array:
array1.forEach(element => element.type = 'ABC');
console.log(array1);

