简体   繁体   中英

How to find if an element in an array that matches a certain condition exists?

Typescript newb question, but I need the fastest way to find if an element with certain condition exists. Is there something like arr.exists(e=>{e.....bla bla bla}) in typescript (where ar is my array of objects).

What you are looking is .find() method of array. It's not anyhow different in TypeScript. Link to docs.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM