HTML and CSS Reference
In-Depth Information
Objective summary
Everything in JavaScript is an object—even functions.
JavaScript supports native objects and custom objects.
Objects are created with the new keyword.
Access methods and properties on objects with the dot notation: object.method or
object.property .
You can create custom objects dynamically or by using prototypes.
Prototypes provide for object definition reuse, whereas dynamic objects require
attributes and methods defined for each use.
Inheritance is achieved in JavaScript through the extension of prototypes.
Objective review
Answer the following questions to test your knowledge of the information in this objective.
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.
In JavaScript, which of the following isn't a native object?
1.
Function
A.
Array
B.
Integer
C.
Person
D.
Which of the following snippets shows the correct way to create a custom book object?
A. var book = “Title: 'My book about things'” + “Author: 'Jane Doe'” + “ Pages: 400”;
B. var book = {Title: “My book about things”, Author: “Jane Doe”, Pages: 400};
C. var book = (Title= “My book about things”, Author= “Jane Doe”= Pages: 400);
D. var book = new {Title: “My book about things”, Author: “Jane Doe”, Pages: 400};
2.
Inheritance is accomplished in JavaScript through the use of which construct?
A. inherits keyword
B. implements keyword
C. this keyword
3.
Prototypes
D.
 
 
Search WWH ::




Custom Search