Object-Oriented Approaches
As I have already mentioned, there are many different ways to approach object-oriented programming with JavaScript. You can create objects or pseudo-objects with any of the following:
Object constructors
Prototypes
The new operator
Literal notation
Associative arrays
JScript.NET
Each of these methods for creating objects or pseudo-objects in JavaScript is valid, yet some are more flexible than others. This does not mean that these methods are not useful—there are definitely situations where a particular method would be better than all the other approaches. Let’s take a brief look at each of these approaches and what situations they would be useful in.
Note
Since this chapter will be focusing in-depth on object constructors ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access