Eager evaluation computes an expression as soon as it is bound to a variable, even when no later operation needs its result. This can waste work when a large result is immediately reduced to a small subset. section 7.2
An unnecessary function call
In Maybe.of(student).getOrElse(createNewStudent()), JavaScript evaluates createNewStudent() before getOrElse decides whether it needs a fallback. A conditional avoids that call when student already exists. section 7.2
Figure 7.6. The composition of the function range (returns a list of numbers from beginning to end) with take (reads the first n elements). In eager evaluation, the range function executes completely, feeding its result to take. With lazy evaluation, the result of range never executes until the dependent operation, take, is called.
Compare eager range generation, which produces everything before take runs, with deferred generation that produces only the requested elements. section 7.2
Reduce eager-work costs by:
- Avoiding needless computations when a result may not be required. section 7.2




