Using a Mixin with Underscore
Learn how to use StorageMixin object instance with Underscore.
We'll cover the following...
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:
Access this course and 1400+ top-rated courses and projects.