Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Underscore.js

What is underscore.js (I think lib like jQuery)? What can it do? Why there is no course on it on treehouse? Is it necessary for javascript developer like other lib (JQuery, Angular)?

Gustavo Winter
Gustavo Winter
Courses Plus Student 27,382 Points

Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects.

Check the Underscore page here.

Why you need that?

Like a developer is good to know every tool available. In some cases you can use the flexibility of the Underscore library to improve your code.

Like this example:

--- > object_.object(list, [values]) Converts arrays into objects. Pass either a single list of [key, value] pairs, or a list of keys, and a list of values. If duplicate keys exist, the last value wins.

_.object(['moe', 'larry', 'curly'], [30, 40, 50]);
=> {moe: 30, larry: 40, curly: 50}

_.object([['moe', 30], ['larry', 40], ['curly', 50]]);
=> {moe: 30, larry: 40, curly: 50}

---> isMatch_.isMatch(object, properties)

Tells you if the keys and values in properties are contained in object.

var stooge = {name: 'moe', age: 32};
_.isMatch(stooge, {age: 32});
=> true

On my opinion, is a good idea to be familiar with this library since it provides tools to make your job easier. Hope this helps.

P.S: You can check all the tools on the oficial Underscore website here.

If you want to check the diferrence between a library and a framework, please Check Here.

1 Answer

Hello, I don't recommend using underscode.js. https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore