javascript - How to convert this mysql select return into one array -


is there anyway convert example below?

convert this:

[   rowdatapacket { title: 'code' },   rowdatapacket { title: 'pizza' } ] 

into this:

['code', 'pizza'] 

i've provided 2 possible solutions, in case if it's array of objects or array of nested objects.

var arr = [{rowdatapacket: { title: 'code' }}, {rowdatapacket: { title: 'pizza' }}],      res = arr.map(v => v.rowdatapacket.title);      console.log(res);

var arr = [{ title: 'code' }, { title: 'pizza' }],      res = arr.map(v => v.title);      console.log(res);


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -