By the end of this tutorial, you’ll use wrapper .next() to walk lazy Lodash sequences one step at a time with { done, value } results.
01
Iterator step
.next()
02
done + value
Result object.
03
Lazy chains
One item at a time.
04
vs .value()
All vs stepwise.
05
Loop pattern
while (!done).
06
With filter
Lazy filter seq.
Fundamentals
What Is Wrapper .next()?
Wrapper .next() advances a lazy Lodash sequence one element at a time. Each call returns { done: boolean, value: any }—the same iterator shape used throughout JavaScript—so you can pull values manually instead of unwrapping everything with .value().
💡
Not _.prototype.next()
There is no _.prototype.next() function. Call .next() on a wrapper: _( [1, 2] ).next() returns { done: false, value: 1 }.
Use wrapper .next() for custom iteration over lazy chains—especially after filter or map when you want step-by-step control or deferred computation rather than materializing the full array upfront.
Start with _(data) or add transforms like filter and map on the wrapper.
Sequence
2
Call .next()
Lodash yields the next value as { done: false, value } or signals end with done: true.
Step
3
Repeat until done
Keep calling .next() on the same wrapper instance—the internal cursor advances each time.
Iterate
=
⚡
Or unwrap in bulk
When you do not need stepwise control, .value() materializes the full result in one call.
Important
📝 Notes
There is no _.prototype.next() function—the correct name is wrapper .next() on a sequence object.
Always check result.done before using result.value—when done is true, value is undefined.
Wrapper .next() follows the same iterator protocol shape as generators and native iterators.
Especially useful after lazy filter or map when you want one element at a time.
For everyday array iteration, native for...of is usually simpler unless you need Lodash lazy chains.
Next in the series: .plant() clones a chain template onto new data.
Wrap Up
Conclusion
Wrapper .next() lets you walk Lodash lazy sequences one step at a time using { done, value } results. It is ideal for custom loops, lazy filters, and iterator-style control when bulk .value() is not what you need.
Next in the wrapper prototype series: .plant(), which reuses a pipeline on a different wrapped value.
Always check result.done before using result.value
Use a while or do...while loop for collecting all values
Prefer .next() on lazy filter/map chains when you need stepwise control
Use .value() when you need the full array or object at once
Reuse the same wrapper instance—each .next() advances its cursor
❌ Don’t
Call it _.prototype.next()—that name does not exist in Lodash
Read result.value when result.done is true
Use .next() on plain arrays when for...of is simpler
Expect .next() to return a wrapper—it returns { done, value }
Create a new wrapper for each step—that resets iteration from the start
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about wrapper .next()
Use these when stepping through lazy Lodash sequences manually.
5
Core concepts
⚡01
Iterator step
.next()
Core
✅02
Check done
Stop when true.
Critical
🔄03
Lazy filter
One match at a time.
Pattern
📦04
vs .value()
Step vs bulk.
Compare
🛠️05
When to use
Lazy chains.
Guideline
❓ Frequently Asked Questions
An object with done (boolean) and value. While elements remain, done is false and value is the next item. When finished, done is true and value is undefined.
.value() runs the entire chain and returns all results at once as plain data. .next() yields one lazy step at a time—useful for manual or memory-conscious iteration.
Same iterator shape { done, value }, but wrapper .next() walks a Lodash lazy sequence (often after map/filter on a wrapper), not a native array iterator directly.
When you want lazy, step-by-step consumption of a wrapped sequence—custom loops, pulling one item at a time, or integrating with iterator-style code.
No. The correct API is wrapper .next() on the object returned by _(value) or _.chain(value).
Yes. Chained transforms like filter create lazy sequences; .next() yields matching elements one by one without computing the full result upfront.
Did you know?
Wrapper .next() uses the standard JavaScript iterator result shape—the same { done, value } object you get from generators. That makes it familiar if you have used for await...of or manual generator iteration.