You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
454 B

4 years ago
  1. # `firstWhere()`
  2. The firstWhere method returns the first element in the collection with the given key / value pair:
  3. ```js
  4. const collection = collect([
  5. { name: 'Regena', age: 12 },
  6. { name: 'Linda', age: 14 },
  7. { name: 'Diego', age: 23 },
  8. { name: 'Linda', age: 84 },
  9. ]);
  10. collection.firstWhere('name', 'Linda');
  11. // { name: 'Linda', age: 14 }
  12. ```
  13. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/firstWhere.js)