Created
September 23, 2018 07:32
-
-
Save minedun6/3b5c1af5b3f4463f8a082e96f0dd62b5 to your computer and use it in GitHub Desktop.
`find` in lodash works like `first` in Laravel's Collection class, but with some extra super power shorthands`find` in lodash works like `first` in Laravel's Collection class, but with some extra super power shorthands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const episodes = [ | |
{number: 68, published: true, listens: 5683, guest: "Jonathan Reinink", title: "Building interfaces with utility-first CSS"}, | |
{number: 60, published: true, listens: 15812, guest: "Michelle Bu", title: "Engineering payments at Stripe"}, | |
{number: 50, published: true, listens: 12198, guest: "Evan You", title: "What's coming in Vue.js 2.0"}, | |
]; | |
_(episodes).find(e => e.listends > 15000) | |
// => {number: 60, published: true, listens: 15812, guest: "Michelle Bu", title: "Engineering payments at Stripe"} | |
_(episodes).find({number: 60, guest: "Evan You"}) | |
// => {number: 50, published: true, listens: 12198, guest: "Evan You", title: "What's coming in Vue.js 2.0"} | |
_(episodes).find(['number', 68]) | |
// => {number: 68, published: true, listens: 5683, guest: "Jonathan Reinink", title: "Building interfaces with utility-first CSS"} | |
_(episodes).find('published') | |
// => {number: 68, published: true, listens: 5683, guest: "Jonathan Reinink", title: "Building interfaces with utility-first CSS"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment