-2

I would like to convert array to a list like :

This :
[ RowDataPacket { id_name: '' } ]


To : 
[ '' ]


I just want a list, whitout name, no 'id_name'

2 Answers2

0

Create a new empty array and when looping your rowDataPacket array, push them to new array.

Example;

// your array = rowDataPackets =[{id_name:''},{id_name:''},...]

const CleanArray = [];

rowDataPackets.forEach( ({ id_name : idName }) => { CleanArray.push(idName) });

console.log(CleanArray);

// CleanArray = ['','',...]
0

You can use Map Array method to iterate over this arr and get the key

const result = [ RowDataPacket { id_name: '' } ].map( item => item.id_name )
Antek Pietryga
  • 346
  • 1
  • 6