Underscore.js Tricks!

If there is one thing I have learned about JavaScript over the past couple weeks is that it is a powerful and immense language. This was reinforced today in class when we learned more JavaScript tricks through the Underscore framework. Below are some of the things I thought were the most impactful and fun to mess with!


This was the first set of functional programming tricks. Here are two that I thought were pretty useful.

_.findWhere can be an efficient way to manipulate and control data to pull values and things that you want it to!

In addition, the _.reject tool will eliminate data that you find unneeded. Check it out!


Next up are arrays, which again, can be useful to run to control and get the data you want. Here are another two examples.

The first example is the _.first array which will return the first value of the array.

Next is the _.rest function which will leave off the first value in the array.


For functions I liked these tools because it allows you to do things like this:

The _.isString tool lets the coder check if you have a string present.

The _.isFinite lets a user check if the number is finite.


The first object I will reference will be the _.extend object.

The second example of an object that I thought was interesting is as follows:


The _.random tool will allow the user to return a number that is random. I did a random number between 0–500!

Lastly, the _.now utility returns an instant timestamp the time that is called.

While I just started the underscore program, these tricks and others will allow for useful running of JavaScript and a faster, cleaner experiences for clients/users.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.