Underscore Chaining_ Power Node Java Acquisition

Remember jQuery support chain call?

$ (‘a’). Attr (‘Target’, ‘_blank’) .append (‘
 ') .click (Function () {});    If we have a set of operations, use the function provided by Underscore, write like this: 

_. Filter ([1, 4, 9, 16, 25], math.sqrt), x => x% 2 === 1); // [1, 3, 5]
 Can you write a chain call?  Can you!  Underscore provides a method of packaging the object package into chain calls, which is a chain () function: 

_ .CHAIN. 1, 4, 9, 16, 25]) .map (Math.SQRT) .filter (x => x% 2 === 1) .Value (); // [1, 3, 5]


Because each step is returned to the package object, the result of the last step needs to call value () to obtain the final result.
Summary
   Is it a further understanding of JavaScript's functional programming by learning Underscore? 
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment