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

4x4 Matrix in Python -

c# - .Net MVC not sorting -

unit testing - Typed racket error with check-random -