Underscore.js _.countBy Function
Underscore.js _.countBy() function is used to sort a list into groups and returns a count for the number of objects in each group. It works by matching the value of each element to the other. If they match then the count of one collection increases by 1 otherwise the count of another collection/group which has that value increases by 1. It can also pass a function based on who will collect the elements and increase the count of each group. It can match both based on numbers and also by string....
read more
Underscore.js _.keys() Function
Underscore.js_.keys() function is used to return the list of all keys of the given object....
read more
Underscore.js _.escape() function
Underscore.js _.escape() function is used to escape a special character string from inserting into HTML. Some of the strings that get escape are “&“, “>“, “<“, “”“, etc....
read more
Underscore.js _.defer() Function
Underscore.js _.defer() function is used to invoke/call a function until the current call stack is cleared. Its major advantage is that it performs expensive computations, calculations, or HTML in chunks without blocking the UI threads from updating. It has a similar functioning to the setTimeOut() function with a delay of 0. The function which is passed to this function will be invoked first.  A call stack is a mechanism for an interpreter like the JavaScript interpreter, to keep track of its place in a script that calls multiple functions....
read more
Underscore.js _.object() Function
_.object() function:...
read more
Underscore.js _.has() Function
Underscore.js _.has() function is used to check whether the given object contains the given key or not....
read more
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 data in interpolating delimiters, execute JavaScript in evaluating delimiters, and HTML-escape interpolated properties of data in escape delimiters. Moreover, data properties are retrieved in the template as free variables....
read more
Underscore.js _.isObject() Function
Underscore.js_.isObject() function is used to check whether the given object is an object or not. It returns a Boolean value True if the given object element is an object and returns False otherwise. JavaScript functions and arrays are objects, while the strings and numbers are not objects....
read more
Underscore.js _.functions() Function
Underscore.js _.functions() function is used to return the sorted list of all methods that are present in an object....
read more
How to use underscore.js as a template engine ?
While writing layouts for web pages, it is often the case that we require certain elements of the page to have dynamic values. For such scenarios, we use templates. Templates enable us to embed logical segments inside static HTML code, which makes the page dynamic based on the values passed in the template. To render templates, we require a template engine. In this article, we will discuss how the popular JavaScript library underscore.js can be used as a template engine....
read more
Underscore.js _.defaults() Function
Underscore.js _.defaults() function returns the object after filling in its undefined properties with the first value present in the following list of default objects....
read more
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....
read more