Creates a lodash object which wraps value to enable implicit chaining. Methods that operate on and return arrays, collections, and functions can be chained together. Methods that retrieve a single value or may return a primitive value will automatically end the chain returning the unwrapped value. Explicit chaining may be enabled using _.chain. The execution of chained methods is lazy, that is, execution is deferred until _#value is implicitly or explicitly called.
Lazy evaluation allows several methods to support shortcut fusion. Shortcut fusion is an optimization strategy which merge iteratee calls; this can help to avoid the creation of intermediate data structures and greatly reduce the number of iteratee executions.
For example, it would be easy to forget the .value(), when comparing to the equivalent ES6 version.
_(Highcharts.charts)
.filter( c => c)
.filter( c => isVisible(c.container))
.forEach(c => console.log(c))
.value(); // Needed to tell lodash to actually run the code
I’m currently taking a course by the technical lead at Netflix that is on ReactiveX. It allows you to use this style of method chaining even for for asynchronous streams of data, which is super cool. The exercises are public for everyone, check it out!: http://reactivex.io/learnrx/