This set of Basic JavaScript Questions and Answers focuses on “Invocation of the Performance Object”.
1. Which of the following property gives access to the JavaScript memory usage data?
a) performance.memory
b) memory(performance)
c) performance(memory)
d) performance()
View Answer
Explanation: The property performance.memory gives access to the JavaScript memory usage data. It returns an object of type ObjectObject.
2. What is the purpose of the timing property in the window.performance object?
a) Time of navigation event
b) Time of page load event
c) Time of navigation and page load event
d) Time of scrolling
View Answer
Explanation: Each performance.timing attribute shows the time of a navigation event (such as when the page was requested) or page load event (such as when the DOM began loading), measured in milliseconds. The legacy Performance.timing read-only property returns a PerformanceTiming object containing latency-related performance information.
3. Which of the following property is associated with the Response event?
a) responseStart
b) responseEnd
c) both responseStart and responseEnd
d) responsiveStart
View Answer
Explanation: PerformanceTiming.responseStart read-only property returns an unsigned long long representing the moment in time (in milliseconds since the UNIX epoch) when the browser received the first byte of the response from the server, cache, or local resource. The properties associated with the Response event are:
- responseStart
- responseEnd.
4. Which of the following computation is correct to calculate the time taken for page load once the page is received from the server?
a) responseEnd-loadEventEnd
b) loadEventEnd-responseEnd
c) loadEventEnd/responseEnd
d) responseEnd/loadEventEnd
View Answer
Explanation: The legacy PerformanceTiming.loadEventEnd read-only property returns an unsigned long representing the moment, in milliseconds since the UNIX epoch, when the load event handler terminated, that is when the load event is completed. The time taken for page load once the page is received from the server: loadEventEnd-responseEnd.
5. Which of the following property is associated with the Processing event?
a) domComplete
b) domContentLoaded
c) domInteractive
d) domload
View Answer
Explanation: PerformanceTiming.domComplete read-only property returns an unsigned long long representing the moment, in miliseconds since the UNIX epoch, when the parser finished its work on the main document. The following properties are associated with the Processing event:
- domComplete
- domContentLoaded
- domInteractive
- domLoading
- unLoadEnd.
6. What does it indicate when the type attribute of the navigation object is set to 2?
a) Navigation by moving back through history
b) Navigation by moving forward through history
c) Navigation by moving back & forward through history
d) Navigation by moving in favorites
View Answer
Explanation: The navigator object contains information about the browser. When the type attribute of the navigation object is set to 2, it means that the navigation is done by moving back or forward through history.
7. What does the method Performance.now() return?
a) DOMTimeStamp
b) DOMHighResTimeStamp
c) DOM\Stamp
d) TimeStamp
View Answer
Explanation: The Performance.now() method returns a DOMHighResTimeStamp, measured in milliseconds, accurate to one thousandth of a millisecond equal to the number of milliseconds since the PerformanceTiming.navigationStart property and the call to the method. The returned value represents the time elapsed since the time origin.
8. Which of the following is a read-only property?
a) PerformanceTiming.navigationStart
b) PerformanceTiming.fetchStart
c) PerformanceTiming.navigationStart & PerformanceTiming.fetchStart
d) PerformanceTiming.responseStart
View Answer
Explanation: PerformanceTiming.navigationStart read-only property returns an unsigned long long representing the moment, in miliseconds since the UNIX epoch, right after the prompt for unload terminates on the previous document in the same browsing context. If there is no previous document, this value will be the same as PerformanceTiming.fetchStart. Both PerformanceTiming.navigationStart and also the PerformanceTiming.fetchStart are a read-only properties.
9. Which of the following is an interface?
a) Time
b) Timing
c) Performance
d) PerformanceTiming
View Answer
Explanation: Performance.timing read-only property returns a PerformanceTiming object containing latency-related performance information. PerformanceTiming is an interface in JavaScript.
10. How many properties are associated with the Response event?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: There are a total of 2 properties associated with the Response event namely:
- PerformanceTiming.responseEnd
- PerformanceTiming.responseStart.
PerformanceTiming.responseStart read-only property returns an unsigned long long representing the moment in time (in milliseconds since the UNIX epoch) when the browser received the first byte of the response from the server, cache, or local resource.
Sanfoundry Global Education & Learning Series – Javascript Programming.
- Practice Information Science MCQs
- Check JavaScript Books
- Practice MCA MCQs
- Check Programming Books
- Apply for Computer Science Internship