I have an array of objects. It looks something like this:
[
{ name: "item1", moreDataHere },
{ name: "item2X", moreDataHere },
{ name: "item3", moreDataHere }
]
I want to remove all items that DON'T end in X. How could I achieve this?
something like this
[
{ name: "item1", },
{ name: "item2X", },
{ name: "item3", }
].filter(x=>x.name.endsWith('X'))
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.