Under the core of Underscore.js

So what is this Underscore?

Underscore is a JavaScript library that improves its robustness.

Collections: A collection can either be an array or an object. Underscore provides a lot of methods like

select:- selects  a set from array based on certain property

pluck:- plucks or extracts a specific property from each key-value pair of array

map:- map creates an array from a collection where each element can be mutated or otherwise changed through a function

all:- all is useful if you need to check every value in a collection passes a certain criteria.

Arrays : Methods like

uniq:-This method basically parses an array and removes all duplicate elements providing you with only unique elements

range:- range lets you create a ‘range’ or list of numbers. The method’s parameters  are, in order, starting value, ending value and step value. Using a negative step value leads to a decrementing range.

intersection:- This method compares two arrays to each others and returns the list of   elements that are found in all of the passed arrays i.e. an intersection in set theory.

Objects: Underscore provides various methods to clone, extend and other manipulate objects.

keys and values:- used when you only need keys or only values.

defaults:-This method is quite useful when you need to create objects with sensible defaults when one might not be used when creating it

Functions: Underscore has functions that work on functions. Most of the functions tend to be fairly complicated to explain.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s