Skip to content

Instantly share code, notes, and snippets.

@junosuarez
Created February 1, 2013 02:16
Show Gist options
  • Save junosuarez/4688640 to your computer and use it in GitHub Desktop.
Save junosuarez/4688640 to your computer and use it in GitHub Desktop.
_.last predicate signature use case
//rather than:
var title = '';
for(var i = things.length-1; i >= 0; i--) {
title = things[i].title;
if (title) {
break;
}
}
// I wanna do:
var title = _.last(things, function (thing) { return thing.title; }).title
@junosuarez
Copy link
Author

/cc @jdalton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment