O'Reilly logo

JavaScript Object Programming by Martin Rinehart

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 9

image

On Constructors

Some say you should never use the new operator in your JavaScript. I use it when I want to create a family of objects all varying in their data properties’ values. That is just what OOP languages do. We think the huge success of C++, Java, and other OOP languages tells you that this paradigm commonly matches at least some of the realities our programs model.

Unfortunately, the new operator’s implementation in JavaScript could hardly be more confusing. Knowing exactly how this operator functions may help you shine in interviews but it will not help you write code.

If you skim or entirely skip this chapter I won’t be disappointed. ...

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