Example 1 — Official Docs Stooges
Sort by age, format a sentence, take the first — unwrap with .value().
var stooges = [
{ name: "curly", age: 25 },
{ name: "moe", age: 21 },
{ name: "larry", age: 23 }
];
_.chain(stooges)
.sortBy(function (s) { return s.age; })
.map(function (s) { return s.name + " is " + s.age; })
.first()
.value();
// → "moe is 21" How It Works
- Wrap.
_.chain(stooges)starts the fluent wrapper. - Sort. Ages become 21 → 23 → 25, so moe is first.
- Map. Each stooge becomes a sentence like
"moe is 21". - First + value. Keep the first sentence, then unwrap the string.

