1let arr = [
2 { name:"string 1", value:"this", other: "that" },
3 { name:"string 2", value:"this", other: "that" }
4];
5
6let obj = arr.find(o => o.name === 'string 1');
7
8console.log(obj);
1var __POSTS = [
2 { id: 1, title: 'Apple', description: 'Description of post 1' },
3 { id: 2, title: 'Orange', description: 'Description of post 2' },
4 { id: 3, title: 'Guava', description: 'Description of post 3' },
5 { id: 4, title: 'Banana', description: 'Description of post 4' }
6];
7
8var __FOUND = __POSTS.find(function(post, index) {
9 if(post.title == 'Guava')
10 return true;
11});
12
13// On success __FOUND will contain the complete element (an object)
14// On failure it will contain undefined
15console.log(__FOUND); // { id: 3, title: 'Guava', description: 'Description of post 3' }
16