Skip to content

Instantly share code, notes, and snippets.

@VincentDamour
Created August 20, 2016 13:48
Show Gist options
  • Save VincentDamour/91addf997e8887021076cdc3197b3fe0 to your computer and use it in GitHub Desktop.
Save VincentDamour/91addf997e8887021076cdc3197b3fe0 to your computer and use it in GitHub Desktop.
var posts = [
{ id: "1abc", title: "First blog post", content: "..." },
{ id: "2abc", title: "Second blog post", content: "..." },
// plus d'articles
{ id: "34abc", title: "The blog post we want", content: "..." }
// encore plus d'article
];
posts = _.keyBy(posts, "id");
var post = posts["34abc"]
// post -> { id: "34abc", title: "The blog post we want", content: "..." }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment