Essential JavaScript and jQuery
- 3/15/2013
Answers
This section contains the answers to the lesson review questions in this chapter.
Lesson 1
Correct answer: C
- Incorrect: A property is a variable that’s defined on an object.
- Incorrect: A method is a function that’s defined on an object.
- Correct: A class is a blueprint for an object.
- Incorrect: An event takes place from external input, usually from user input.
Correct answer: A
- Correct: The prototype is the starting object that is cloned when creating a new object.
- Incorrect: A property is a variable that’s defined on an object.
- Incorrect: A class is a blueprint for an object.
- Incorrect: An event takes place from external input, usually from user input.
Correct answer: A
- Correct: 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.
- Incorrect: The createChild method is not a valid method.
- Incorrect: The setParent method is not a valid method.
- Incorrect: JavaScript does support inheritance by replacing the prototype of the child object with a new instance of the parent object and then replacing the prototype constructor with the child constructor.
Lesson 2
Correct answer: B
- Incorrect: The use of the hash (#) symbol in the CSS selector indicates that you want to locate an element based on its id.
- Correct: The use of the period (.) in the CSS selector indicates that you want to locate the elements that match the CSS class name.
- Incorrect: Supplying a name for a CSS selector indicates that you want to locate the elements that have that tag name.
- Incorrect: The var hidden = $(‘class=Hidden’); syntax is invalid.
Correct answer: A
- Correct: Using jQuery will help you create event-driven, browser-independent code.
- Incorrect: The code for creating and subscribing to events is browser-specific.
- Incorrect: You need to use JavaScript to write event-driven code.
- Incorrect: Use the jQuery library to write browser-independent code.
Correct answer: C
- Incorrect: jQuery does not have an exists property.
- Incorrect: Even if no elements are found, jQuery will return a wrapper object.
- Correct: If no elements are found, the length property will be 0, which converts to a Boolean false.
- Incorrect: jQuery does not have a count property.