Underscore.js

What is Underscore.js ?

Underscore.js is a lightweight JavaScript library and not a complete framework that was written by Jeremy Ashkenas. It provides utility functions for a variety of use cases in our day-to-day common programming tasks. Underscore.js provides a lot of features that make our task easy to work with objects. It can be used directly inside a browser and also with Node.js.

Underscore Tutorial

Underscore Tutorial

Why Underscore.js ?

With just under six kilobytes in size, this library basically provides us with a whole bunch of useful JavaScript functions for making our life easier. There are literally hundreds of different functions available that support both our workaday functional helpers such as the map and filter functions, as well as more specialized ones such as JavaScript templating, function binding, deep equality testing, creating quick indexes, and many more. Underscore.js functions basically falls under four major categories which are functions that can be used for manipulating arrays, functions that can be used for manipulating objects, functions that can be used for manipulating both arrays as well as objects, and functions that can be used for manipulating other functions itself.

How to Install and use Underscore.js ?

We can use Underscore.js directly inside the browser and also with node.js. We will discuss both of these methods.

Method 1: Using CDN Link

Visit the official website (https://underscorejs.org/) and download the latest underscore-min.js file UMD available. After that include the following CDN link inside your code in order to run the underscore.js code inside the browser.

Method 2: Using nmp or yarn Package Manager

We can install it with npm. Make sure that you have Node.js and npm installed.

npm install underscore

You can also install with yarn

yarn install underscore

Now let’s understand the working of code through an example.

Features of Underscore.js

  • Perform common operations of data like arrays, objects, JSON files, etc.
  • Compatible with other JS libraries like jQuery to perform DOM operations.
  • Contains function for data manipulation.

Learn more about Underscore.js

Underscore.js Collections Methods

Underscore.js Array Methods

Underscore.js Functions

Underscore.js Object Methods

Underscore.js Utility Methods

 

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above



  • Last Updated : 05 Oct, 2023

Share your thoughts in the comments
Similar Reads