简体   繁体   English

如何查找数组中与特定条件匹配的元素是否存在?

[英]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. Typescript newb 问题,但我需要最快的方法来查找具有特定条件的元素是否存在。 Is there something like arr.exists(e=>{e.....bla bla bla}) in typescript (where ar is my array of objects). arr.exists(e=>{e.....bla bla bla})是否有类似arr.exists(e=>{e.....bla bla bla})的东西(其中 ar 是我的对象数组)。

What you are looking is .find() method of array.您正在寻找的是数组的.find()方法。 It's not anyhow different in TypeScript.它在 TypeScript 中并没有什么不同。 Link to docs. 链接到文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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