Using a Mixin with Underscore

Learn how to use StorageMixin object instance with Underscore.

At this point, we’re able to create a new constructor and have it assigned to the original reference. However, we still haven’t done anything about configuring local storage, which is what we originally set out to do.

Using the extend function

Underscore provides an extend function that allows us to copy-paste the properties of a source object into a destination object. This is the same function we use when defining something, e.g., a collection. We extend Backbone’s collection so that we can use the functions defined by Backbone.

Creating a configureStorage function

Let’s create a configureStorage function that will extend our entity prototypes:

Get hands-on with 1200+ tech skills courses.