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.
Why Underscore.js?
With just under six kilobytes in size, this library provides us with many useful JavaScript functions for making our lives easier. There are 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 fall 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 themselves.
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
Include the following CDN link inside your code in order to run the underscore.js code inside the browser.
https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js
Method 2: Using nmp or yarn Package Manager
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 Collection Methods
- Underscore.js Array Methods
- Underscore.js Functions
- Underscore.js Object Methods
- Underscore.js Utility Methods
Underscore.js Collections Methods
- Underscore.js _.each() Method
- Underscore.js _.map() Method
- Underscore.js _.reduce() Method
- Underscore.js _.reduceRight() Method
- Underscore.js _.find() Method
- Underscore.js _.filter() Method
- Underscore.js _.where() Method
- Underscore.js _.findWhere() Method
- Underscore.js _.reject() Method
- Underscore.js _.every() Method
- Underscore.js _.some() Method
- Underscore.js _.contains() Method
- Underscore.js _.invokes() Method
- Underscore.js _.pluck() Method
- Underscore.js _.max() Method
- Underscore.js _.min() Method
- Underscore.js _.sortBy() Method
- Underscore.js _.groupBy() Method
- Underscore.js _.indexBy() Method
- Underscore.js _.countBy() Method
- Underscore.js _.shuffle() Method
- Underscore.js _.toArray() Method
- Underscore.js _.size() Method
- Underscore.js _.partition() Method
- Underscore.js Collections Complete Reference
Underscore.js Array Methods
- Underscore.js _.first() Method
- Underscore.js _.initial() Method
- Underscore.js _.last() Method
- Underscore.js _.rest() Method
- Underscore.js _.compact() Method
- Underscore.js _.flatten() Method
- Underscore.js _.without() Method
- Underscore.js _.union() Method
- Underscore.js _.intersection() Method
- Underscore.js _.difference() Method
- Underscore.js _.uniq() Method
- Underscore.js _.zip() Method
- Underscore.js _.unzip() Method
- Underscore.js _.object() Method
- Underscore.js _.chunk() Method
- Underscore.js _.indexOf() Method
- Underscore.js _.lastIndexOf() Method
- Underscore.js _.sortedIndex() Method
- Underscore.js _.findIndex() Method
- Underscore.js _.findLastIndex() Method
- Underscore.js _.range() Method
- Underscore.js Array Complete Reference
Underscore.js Functions
- Underscore.js _.bind() Method
- Underscore.js _.bindAll() Method
- Underscore.js _.partial() Method
- Underscore.js _.memoize() Method
- Underscore.js _.delay() Method
- Underscore.js _.defer() Method
- Underscore.js _.throttle() Method
- Underscore.js _.debounce() Method
- Underscore.js _.once() Method
- Underscore.js _.after() Method
- Underscore.js _.before() Method
- Underscore.js _.wrap() Method
- Underscore.js _.negate() Method
- Underscore.js _.compose() Method
- Underscore.js _.restArguments() Method
- Underscore.js Functions Complete Reference
Underscore.js Object Methods
- Underscore.js _.keys() Method
- Underscore.js _.allKeys() Method
- Underscore.js _.values() Method
- Underscore.js _.mapObject() Method
- Underscore.js _.pairs() Method
- Underscore.js _.invert() Method
- Underscore.js _.create() Method
- Underscore.js _.functions() Method
- Underscore.js _.findKey() Method
- Underscore.js _.extend() Method
- Underscore.js _.extendOwn() Method
- Underscore.js _.pick() Method
- Underscore.js _.omit() Method
- Underscore.js _.defaults() Method
- Underscore.js _.clone() Method
- Underscore.js _.tap() Method
- Underscore.js _.property() Method
- Underscore.js _.propertyOf() Method
- Underscore.js _.matcher() Method
- Underscore.js _.isEqual() Method
- Underscore.js _.isMatch() Method
- Underscore.js _.isEmpty() Method
- Underscore.js _.isElement() Method
- Underscore.js _.isArray() Method
- Underscore.js _.isObject() Method
- Underscore.js _.isArguments() Method
- Underscore.js _.isFunction() Method
- Underscore.js _.isString() Method
- Underscore.js _.isNumber() Method
- Underscore.js _.isFinite() Method
- Underscore.js _.isBoolean() Method
- Underscore.js _.isDate() Method
- Underscore.js _.isRegExp() Method
- Underscore.js _.isError() Method
- Underscore.js _.isSymbol() Method
- Underscore.js _.isMap() Method
- Underscore.js _.isWeakMap() Method
- Underscore.js _.isSet() Method
- Underscore.js _.isWeakSet() Method
- Underscore.js _.isArrayBuffer() Method
- Underscore.js _.isNaN() Method
- Underscore.js _.isNull() Method
- Underscore.js _.isUndefined() Method
- Underscore.js Objects Complete Reference
Underscore.js Utility Methods
- Underscore.js _.noConflict() Method
- Underscore.js _.identity() Method
- Underscore.js _.constant() Method
- Underscore.js _.noop() Method
- Underscore.js _.times() Method
- Underscore.js _.random() Method
- Underscore.js _.mixin() Method
- Underscore.js _.iteratee() Method
- Underscore.js _.uniqueId() Method
- Underscore.js _.escape() Method
- Underscore.js _.unescape() Method
- Underscore.js _.result() Method
- Underscore.js _.now() Method
- Underscore.js _.template() Method
- Underscore.js Utility Complete Reference