Constructors

IIFEs let you take advantage of function scope to create namespaces to organize large pieces of your code. There is another use of functions that makes them act like factories for objects that all have similar properties and methods. In other languages, you might use a class for this kind of organization. Strictly speaking, JavaScript does not have classes, but it does give you a way to create custom types.

You have already started to create the DataStore type. Now you will customize it in two steps. In the first step, you will give it a property that will be used internally for storing data. In the second step, you will give it a set of methods for interacting with that data. You do not need to give other objects direct ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.