February 2014
Intermediate to advanced
120 pages
2h 30m
English
You might be able to get pretty far in JavaScript without understanding constructors and prototypes, but you won’t truly appreciate the language without a good grasp of them. Because JavaScript lacks classes, it turns to constructors and prototypes to bring a similar order to objects. But just because some of the patterns resemble classes doesn’t mean they behave the same way. In this chapter, you’ll explore constructors and prototypes in detail to see how JavaScript uses them to create objects.
A constructor is simply a function that is used with new to create an object. Up to this point, you’ve seen several of the built-in JavaScript constructors, such as Object, Array, and Function. The advantage ...
Read now
Unlock full access