Underscore.js _.partition Function Last Updated : 27 Dec, 2021 Comments Improve Suggest changes Like Article Like Report The _.partition() function is used to get an array as input and returns two arrays. The first array containing those elements that satisfy the predicate (condition) and the second array contains the remaining elements. Syntax: _.partition(list, predicate) Parameters: This function accepts two parameters as mentioned above and described below: list: This parameter holds the list of items. predicate: This parameter holds the truth condition. Return Value: This function returns two separated array based on predicate condition. Example 1: html <!DOCTYPE html> <html> <head> <script type="text/javascript" src= "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"> </script> </head> <body> <script type="text/javascript"> (function () { var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; var division = _.partition(arr, function (element) { return element % 2 != 0; }); console.log(division); }()); </script> </body> </html> Output: Example 2: html <!DOCTYPE html> <html> <head> <script type="text/javascript" src= "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"> </script> </head> <body> <script type="text/javascript"> (function () { var words = ["javascript", "java", "unix", "hypertext", "underscore", "CSS"]; var part = _.partition(words, function (element) { return element.length > 4; }); console.log(part); }()); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article Underscore.js _.partition Function A ashokjaiswal Follow Improve Article Tags : JavaScript Web Technologies JavaScript - Underscore.js Similar Reads Underscore.js _.partial() Function The _.partial() function is used to apply partially a function by filling in any number of its arguments, without changing its dynamic value. Syntax: _.partial(function, *arguments) Parameters: This function accept two parameters as mentioned above and described below: function: The function that ne 1 min read Underscore.js _.mixin() Function Underscore.js is a JavaScript library that makes operations on arrays, string, objects much easier and handy. The _.mixin() function is used to add extra functionality and extend the global underscore object to some special utility functions. Its important to link the underscore CDN before going and 2 min read Underscore.js _.pairs() Function Underscore.js _.pairs() function is used to convert an object into an array of arrays that contain the [key, value] pairs of the object as elements. Syntax:_.pairs( object );Parameters:object: It contains the object element that holds the elements of key and value pair.Return Value:It returns the ar 1 min read Underscore.js _.template() Function Underscore.js _.template() function is used to compile JavaScript templates into functions that can be evaluated for rendering. Useful for rendering complicated bits of HTML from JSON data sources. Template functions to create a template function that is compiled and can interpolate properties of da 2 min read Underscore.js _.mod() Function The _.mod() function returns the remainder of dividing the given dividend by the given divisor. Syntax: _.mod( dividend, divisor ); Parameters: dividend: given dividend from which mod is calculated.divisor: given divisor which is used to calculate the modulus. Return Value: This method returns the c 1 min read Like