284 CHAPTER 6 Essential JavaScript and jQuery
■■JavaScript is a prototype-based, object-oriented programming language. A prototype
is the object used to create a new instance.
■■The literal pattern can be used to create an object by using curly braces to create the
object. The factory pattern can be used to create a dynamic object.
■■JavaScript does not have a class keyword, but you can simulate a class by defining a
function.
■■Creating private members is possible but usually involves creating privileged getter
methods that can be memory consuming.
■■The new keyword constructs an object instance.
■■The function is an object. The function that simulates a class is called the constructor
function.
■■Namespaces can be created by using an immediately invoked function
expression (IIFE).
Lesson review
Answer the following questions to test your knowledge of the information in this lesson. You
can find the answers to these questions and explanations of why each answer choice is correct
or incorrect in the “Answers” section at the end of this chapter.
- What is the blueprint for an object called?
A. property
B. method
C. class
D. event - What does JavaScript use as a starting object when constructing a new object?
A. prototype
B. property
C. class
D. event - How is inheritance supported in JavaScript?
A. You replace the prototype of the child object with a new instance of the parent
object and then replace the prototype constructor with the child constructor.
B. You call the createChild method on the parent object.
C. You call the setParent method on the child object.
D. JavaScript does not support inheritance.