Underscore.js _.iterators.accumulate() method Last Updated : 11 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report With the help of _.iterators.accumulate(iter, binaryFn) method, we can get the new iterator function which when called will iterate the next step with iter and generate the value by using binaryFn. Syntax: _.iterators.accumulate(iter, binaryFn) Return: Return the iterator function which will generally result in an accumulated Binary function. Example 1: In this example, we can see that by using _.iterators.accumulate(iter, binaryFn) method, we are able to get the function iterator which will return the value by using the accumulated binary function. javascript // Defining underscore contrib variable const _ = require('underscore-contrib'); let iter = _.iterators.List(["Geeks", "for", "Geeks"]); function calculateLength(geeky, element) { return element.length; } let gfg = _.iterators.accumulate(iter, calculateLength, 0); for (let i = 0; i < 3; i++) { console.log(gfg()); } Output: 5 3 5 Example 2: In this example, we will see the use of _.iterators.accumulate(iter, binaryFn) method. javascript // Defining underscore contrib variable const _ = require('underscore-contrib'); let iter = _.iterators.List(["A", "AB", "ABC", "AB", "A"]); function calculateLength(geeky, element) { return element.length; } let gfg = _.iterators.accumulate(iter, calculateLength, 0); for (let i = 0; i < 5; i++) { console.log(gfg()); } Output: 1 2 3 2 1 Comment More infoAdvertise with us Next Article Underscore.js _.iterators.foldl() Method J jitender_1998 Follow Improve Article Tags : JavaScript Web Technologies Node.js JavaScript - Underscore.js Similar Reads Underscore.js _.iterators.accumulateWithReturn() method With the help of _.iterators.accumulateWithReturn() method, we can expect to return two values in an array when the iterator function is called the output of the current iteration is passed to the next iteration value by using this method. Syntax: _.iterators.accumulateWithReturn(iter, binaryFn, ini 2 min read Underscore.js _.iterators.foldl() Method With the help of _.iterators.foldl() method, we can get the single from the iterator when we called it because it will convert all the values into one by boiling down the given values by using this method. Syntax: _.iterators.foldl(iter, binaryFn) Parameter: This method accepts two parameters as men 2 min read Underscore.js _.iterators.K() Method With the help of _.iterators.K() method, we can get the function which when called generate a value from the given value by using this method. Syntax: _.iterators.K(value) Parameter: This method accepts a single parameter as mentioned above and described below: value: This parameter holds the given 1 min read Underscore.js _.iterators.drop() method With the help of _.iterators.drop() method, we can get the values whenever we call the iterator but drops the values till the numberToDrop value and return the generated value by using this method. Syntax:Â _.iterators.drop(iter, numberToDrop) Return: Return the values by the iterator after dropping 1 min read Underscore.js _.iterators.map() method With the help of _.iterators.map() method, we can get the function of the new iterator which will return the value of the unary function which uses the values of the List iterator by using this method. Syntax:Â _.iterators.map(iter, unaryFn) Return: Return the value from the new iterator function. I 2 min read Underscore.js _.iterators.List() Method With the help of _.iterators.List() method, we can get the iterator which when called up gives the next value of the List by using this method. Syntax :Â _.iterators.List(array:Array) Parameters value: This method accepts a single parameter as mentioned above and described below: array: It holds the 1 min read Like