O'Reilly logo

Mastering JavaScript Design Patterns - Second Edition by Simon Timms

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tips and tricks

There are two excellent libraries for working with collections functionally in JavaScript: Underscore.js and Lo-Dash. Used in combination with TypeScript or BabelJS they have a very pleasant syntax and provide immense power.

For instance, finding all the members of a collection that satisfy a condition using Underscore looks like the following:

_.filter(collection, (item) => item.Id > 3);

This code will find all the items where the ID is greater than 3.

Either of these libraries is one of the first things I add to a new project. Underscore is actually bundled with backbone.js, an MVVM framework.

Tasks for Grunt and Gulp exist for compiling code written in TypeScript or BabelJS. There is, of course, also good support for TypeScript in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required