Quiz 4 Flashcards
Case-Based Critical Thinking Questions
Case 9-2
Robin maintains a web page for updating the metro timings in the city. He would like the website to display the present day’s schedule. To do this, Robin writes a code that includes an object to retrieve the day of the week and then loads the appropriate data into the page.
Identify an expression that Robin must use to define the current date on the web page.
A) this Day(“day”, “month”, “hrs”, “mins”, “secs”, “year”),
B) new date(“hrs”, “mins”, “secs”, “day”, “month”, “year”);
C) new Date(year, month, day, hrs, mins, secs);
D) this.day(hrs, mins, secs, year, month, day),
C) new Date(year, month, day, hrs, mins, secs);
T/F: JavaScript demands strict application of rules for syntax and program structure.
F
In the evt.eventPhase property, identify the phase of the event propagation the object is currently at when its value is 2.
A) NONE
B) BUBBLING_PHASE
C) CAPTURING_PHASE
D) AT_TARGET
D) AT_TARGET
Explanation:
- NONE
- CAPTURING_PHASE - The event flow is in capturing phase
- AT_TARGET - The event flow is in target phase, i.e. it is being evaluated at the event target
- BUBBLING_PHASE - The event flow is in bubbling phase
T/F: The event object contains properties and methods associated with an event.
T
Identify the sequence of the occurrence of events when a user types a keyboard key.
A) keydown,keypress,keyup
B) keyup,keydown,keypress
C) keyup,keypress,keydown
D) keydown,keyup,keypress
A) keydown,keypress,keyup
Identify a function that extracts the first numeric value from the textstring.
A) parseFloat(string)
B) isFinite(value)
C) parseInt(string)
D) isNaN(value)
A) parseFloat(string)
Identify acompare function that sorts numeric values in descending order.
A) function descending(a, b) {
return b - a;
}
B) function descending(a, b) {
return a - b;
}
C) function descending(b, a) {
return b;
}
D) function descending(b, a) {
return a;
}
A) function descending(a, b) {
return b - a;
}
Which of the following can be referenced only after the browser has finished parsing the page content?
A) Document objects
B) Browser objects
C) Customized objects
D) Built-in objects
A) Document objects
The _____ looptests the condition to continue the loop right after the latest command block is run.
A) for
B) forEach
C) while
D) do/while
D) do/while
Identify thesyntax of thestatementlabel.
A) statement!(label)
B) statements.label
C) label = {statements}
D) label: statements
D) label: statements
The _____ object property references the browser window in which the event has occurred.
A) evt.target
B) evt.eventphase
C) evt.currentTarget
D) evt.view
D) evt.view
Identify a command that uses the dateDiv variable to refer the page element with ID dateNow.
A) var dateNow = document.getElementById(dateDiv), B) var dateDiv = document.getElementById(“dateNow”); C) var dateDiv = document.getElementById(dateNow), D) var dateNow = document.getElementById(“dateDiv”);
B) var dateDiv = document.getElementById(“dateNow”);
Which of the following is a true statement about an event listener?
A) It allows a function to override another when multiple functions are added.
B) It permits only one function to be applied to an event listener at a time.
C) It describes how events and objects
interact within a web page and a web browser.
D) It responds to events during the target phase but does not recognize the propagation of events through the capture and bubbling phases.
A) It allows a function to override another when multiple functions are added.
T/F: A command block is indicated by its opening and closing square brackets [ ].
F
Which of the following is the syntax to define a cursor in JavaScript? A) object.style = cursorTypes; B) object.style.cursorTypes = cursor; C) object.style.cursor = cursorTypes; D) object.cursorTypes = cursor.style;
C) object.style.cursor = cursorTypes;