Skip to content

Repository files navigation

find

Find the first matching value in an array.

Installation

$ component install component/find

API

find(array, fn)

Find with a function:

vartobi=find(users,function(u){returnu.name=='Tobi'});

find(array, string)

Find with property strings:

find(users,'admin');

find(array, object)

Find with object value matching:

varusers=[];users.push({name: 'Tobi',age: 2,species: 'ferret'});users.push({name: 'Jane',age: 6,species: 'ferret'});users.push({name: 'Luna',age: 2,species: 'cat'});find(users,{name: 'Jane',age: 6});// => { name: 'Jane', age: 6, species: 'ferret' }find(users,{name: 'Jane',age: 1});// => undefined

License

MIT

About

Return the first matching value in an array

Resources

Stars

12 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages