i would like to extract filterPillvalue and put it into an array, and output of the array should be like this:
mode = ['anyValue','Repsonding','Unresponsive']
Here is my attempt
this.items = [
{
filterPillValue: 'anyValue',
id: 'all-systems',
label: 'All systems'
},
{
filterPillValue: 'Responding',
id: 'responding',
label: 'Responding systems'
},
{
filterPillValue: 'Unresponsive',
id: 'unresponsive',
label: 'Unresponsive systems'
}
];
my attempt which does not work in this case
mode = this.items.filter(x=>x.filterPillValue);
This will work.
mode = this.items.map(({filterPillValue}) => filterPillValue);
or
mode = this.items.map((item) => item.filterPillValue);
items = [ { filterPillValue: 'anyValue', id: 'all-systems', label: 'All systems' }, { filterPillValue: 'Responding', id: 'responding', label: 'Responding systems' }, { filterPillValue: 'Unresponsive', id: 'unresponsive', label: 'Unresponsive systems' } ]; const node=items.map(item=>item.filterPillValue) console.log(node)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.