Lazy evaluation

With the introduction of Lo-Dash 3.0, some functions use a lazy evaluation to compute their results. This simply means that the items in a given collection aren't iterated over until they're actually needed. It's figuring out when they're needed that is the tricky part. For example, just calling a single Lo-Dash function doesn't invoke any lazy evaluation mechanism. However, operations that are chained together could certainly benefit from this approach, in certain circumstances. For example, when we're only taking 10 items from the result, there's no need to iterate over the entire collection further up the chain.

To get an idea of what a lazy evaluation looks like, let's write some code to utilize it. There's nothing explicit ...

Get Lo-Dash Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.