O'Reilly logo

The Principles of Object-Oriented JavaScript by Nicholas C. Zakas

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

Chapter 6. Object Patterns

JavaScript has many patterns for creating objects, and there’s usually more than one way to accomplish the same thing. You can define your own custom types or your own generic objects whenever you want. You can use inheritance to share behavior between objects, or you can employ other techniques, such as mixins. You can also take advantage of advanced JavaScript features to prevent an object’s structure from being modified. The patterns discussed in this chapter give you powerful ways of managing and creating objects, all based on your use cases.

Private and Privileged Members

All object properties in JavaScript are public, and there’s no explicit way to indicate that a property shouldn’t be accessed from outside a particular ...

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