WHAT'S IN THIS CHAPTER?
- Working with objects
- Working with primitives and primitive wrappers
WROX.COM DOWNLOADS FOR THIS CHAPTER
Please note that all the code examples for this chapter are available as a part of this chapter's code download on the book's website at
A reference value (object) is an instance of a specific reference type. In ECMAScript, reference types are structures used to group data and functionality together and are often incorrectly called classes. Although technically an object-oriented language, ECMAScript lacks some basic constructs that have traditionally been associated with object-oriented programming, including classes and interfaces. Reference types are also sometimes called object definitions because they describe the properties and methods that objects should have.
Again, objects are considered to be instances of a particular reference type. New objects are created by using the
new operator followed by a constructor. A constructor is simply a function whose purpose is to create a new object. Consider the following line of code:
let now = new Date();
This code creates a new instance of the
Date reference type and stores it in the variable