Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

What does the method Performance.now() return?(a) DOMTimeStamp(b) DOMHighResTimeStamp(c) DOM\Stamp(d) TimeStampI got this question in an online quiz.The origin of the question is Invocation of the Performance Object topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

The correct choice is (B) DOMHighResTimeStamp

The best I can explain: 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.

52.

Which of the following property is associated with the Processing event?(a) domComplete(b) domContentLoaded(c) domInteractive(d) domloadI had been asked this question in quiz.My question is taken from Invocation of the Performance Object in portion Invocation and Performance Navigation of JavaScript

Answer»

The correct choice is (d) domload

Easy 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.

53.

Which of the following does not serialize the undefined values or objects within an object?(a) JSON.string(b) JSON(c) JSON.stringify(d) JSON.change()The question was posed to me by my school teacher while I was bunking the class.My question is taken from Integrating the Performance Object with perfLogger topic in section Invocation and Performance Navigation of JavaScript

Answer»

The correct answer is (c) JSON.stringify

Best EXPLANATION: JSON.stringify does not SERIALIZE undefined values or FUNCTIONS within an object. JSON.stringify() converts a JavaScript object into a string.

54.

What is the purpose of holding whatever tag you create in the attribute type?(a) To have more information(b) To identify the scripting language(c) To store data(d) To store variable nameI had been asked this question in a national level competition.My query is from Lazy Loading topic in portion Invocation and Performance Navigation of JavaScript

Answer»

Correct answer is (b) To identify the SCRIPTING language

Easiest explanation: A VARIABLE is created to HOLD whatever tag you create, and then branch the logic based on the value of type, which IDENTIFIES it’s for JavaScript or for CSS. Hence, the ATTRIBUTE acts as an identifier to the tag.

55.

How is the render time calculated?(a) Date.Now()(b) Date.Now() – performance.timing.domLoading(c) performance.domLoading(d) Date.Now() – performance.domLoadingThe question was posed to me in an interview.Origin of the question is Lazy Loading topic in division Invocation and Performance Navigation of JavaScript

Answer»

Right choice is (B) Date.Now() – performance.timing.domLoading

The explanation is: The rendering ENGINE parses the HTML and the CSS and displays the parsed content on the screen. The render time is calculated as Date.Now() – performance.timing.domLoading.

56.

What is the result when the showPerformanceMetrics() is called before loading the remote script?(a) Throws an exception(b) Throws an error(c) It will load by itself(d) Throws an exception and It will load by itselfThis question was posed to me in semester exam.This interesting question is from Lazy Loading in chapter Invocation and Performance Navigation of JavaScript

Answer» CORRECT ANSWER is (b) Throws an ERROR

The BEST I can explain: perflogger.showPerformanceMetrics() tells the user about the performance parameters of the script loading. If you try to make the call to perfLogger.showPerformanceMetrics() and the script hasn’t just LOADED but also executed, then you will get an error.
57.

What is the purpose of lazy loading?(a) Immediate loading is necessary(b) Loading under command(c) Immediate loading is not necessary(d) Loading after a definite intervalThe question was posed to me in an interview.The origin of the question is Lazy Loading in portion Invocation and Performance Navigation of JavaScript

Answer»

Correct choice is (c) Immediate LOADING is not necessary

Explanation: Lazy loading is a DESIGN PATTERN commonly used in COMPUTER programming to defer initialization of an object until the point at which it is needed. It can CONTRIBUTE to efficiency in the program’s operation if properly and appropriately used. Lazy loading is a kind of loading in which we don’t need our JavaScript code to be available as soon as the page loads.

58.

What is the method to create a data frame?(a) frame(data)(b) frameData()(c) data.frame()(d) frame.Data()This question was posed to me during an online interview.My question is based upon Script Loading topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

Correct answer is (c) DATA.frame()

Easy EXPLANATION: A Data frame is a two-dimensional data structure, i.e., data is ALIGNED in a tabular fashion in rows and COLUMNS.

59.

What should be the type of script_url?(a) Object(b) String(c) Array(d) Any of the mentionedI got this question at a job interview.My query is from Script Loading topic in section Invocation and Performance Navigation of JavaScript

Answer»

The CORRECT answer is (d) Any of the mentioned

To explain: The TYPE of script_url can be anything that will be compared with the typeof keyword’s result. The src ATTRIBUTE SPECIFIES the location (URL) of the external resource.

60.

What will happen if the browser encounters a script tag without an src attribute?(a) Throws an error(b) Throws an exception(c) Sends it to the compiler(d) Sends it to the interpreterThis question was addressed to me by my college director while I was bunking the class.Origin of the question is Script Loading topic in portion Invocation and Performance Navigation of JavaScript

Answer»

The correct CHOICE is (d) Sends it to the interpreter

The EXPLANATION: If the browser encounters a script tag without an src attribute, the rendering ENGINE SIMPLY PASSES the code to the JavaScript Interpreter for execution. The src attribute specifies the location (URL) of the external resource.

61.

What is the initial step to set up a CSS Lazy Loading?(a) Fetching data(b) Loading the script(c) Loading the page(d) Adding the event listenerThis question was posed to me during an online exam.This question is from Lazy Loading topic in portion Invocation and Performance Navigation of JavaScript

Answer»

Right option is (a) Fetching data

Easy EXPLANATION: The LOADING attribute allows a browser to defer loading offscreen images and iframes until USERS scroll NEAR them. The CSS Lazy Loading is begun with fetching the JAVASCRIPT and the CSS files.

62.

When does the browser stop rendering the HTML?(a) Inline JavaScript block(b) External JavaScript file(c) Both Inline JavaScript block & External JavaScript file(d) External HTML fileThis question was addressed to me during an interview.My doubt is from Page Render BottleNecks Optimization in portion Invocation and Performance Navigation of JavaScript

Answer» RIGHT CHOICE is (c) Both Inline JavaScript block & External JavaScript file

Easy explanation: When the BROWSER parses the HTML markup, it stops rendering the HTML when it ENCOUNTERS an inline JavaScript block or external JavaScript file. At this point, the user experiences rendering delays.
63.

Which of the following property is associated with the Request event?(a) requestStart(b) requestEnd(c) both requestStart and requestEnd(d) requestchangeThe question was posed to me at a job interview.Query is from Integrating the Performance Object with perfLogger in section Invocation and Performance Navigation of JavaScript

Answer» CORRECT answer is (a) REQUESTSTART

Easiest explanation: The REQUEST EVENT has only one property: requestStart. The Request event has only one property: requestStart.
64.

How to lazy load images?(a) Remove the rel attribute(b) Remove the src attribute(c) Make rel = src(d) Make src = relThe question was asked during an interview.I would like to ask this question from Lazy Loading in chapter Invocation and Performance Navigation of JavaScript

Answer»

Correct answer is (b) Remove the SRC ATTRIBUTE

Best explanation: The way we WOULD lazy load images would be to ALTER the HTML of the page to remove the contents of the src attribute of each image. We could just move the contents of the src attribute to an attribute in the image tag of our own design, maybe the rel attribute.

65.

How to get a particular value using the tagged name?(a) getElementbyID()(b) getElementsbyName()(c) getElementsbyTagName()(d) getTagName()I have been asked this question in an internship interview.The question is from Script Loading topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

Correct option is (c) getElementsbyTagName()

For explanation I would say: The getElementsByTagName() method returns a COLLECTION of all ELEMENTS in the document with the specified tag name, as a NodeList object. The method getElementsbyTagName() can be used to get a PARTICULAR value USING the tagged name associated with the document.

66.

What are the parameters of the attachEvent function?(a) Function(b) Function, Event(c) Event, Function(d) EventThe question was asked in semester exam.The origin of the question is Lazy Loading topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

Correct option is (c) Event, Function

To EXPLAIN: The ADDEVENTLISTENER() method attaches an event handler to an element without OVERWRITING existing event handlers. The attachEvent function accepts two PARAMETERS: the event to attach to, and the function to INVOKE when the event occurs.

67.

How many properties are there in window.performance object?(a) 1(b) 4(c) 2(d) 3The question was asked during an interview for a job.This is a very interesting question from Integrating the Performance Object with perfLogger in chapter Invocation and Performance Navigation of JavaScript

Answer»

The CORRECT CHOICE is (c) 2

Easy explanation: The Window interface’s performance property returns a Performance OBJECT, which can be used to gather performance INFORMATION about the current document. There are totally 2 properties associated with the window.performance and they are:

navigation

type.

68.

Which of the following is an interface?(a) Time(b) Timing(c) Performance(d) PerformanceTimingThe question was asked in class test.I would like to ask this question from Invocation of the Performance Object topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

Correct choice is (d) PerformanceTiming

The EXPLANATION is: Performance.timing read-only PROPERTY RETURNS a PerformanceTiming OBJECT containing latency-related performance information. PerformanceTiming is an INTERFACE in JavaScript.

69.

What is the purpose of the method createDocumentFragment()?(a) Creates a fragment object(b) Creates a document fragment(c) Creates imaginary node object(d) Create a node fragmentI had been asked this question in final exam.Enquiry is from Script Loading topic in division Invocation and Performance Navigation of JavaScript

Answer»

Correct choice is (c) Creates IMAGINARY node object

Explanation: The createDocumentFragment() METHOD creates a imaginary Node object, with all the PROPERTIES and methods of the Node object. DocumentFragments are DOM Nodes. They are NEVER part of the main DOM TREE.

70.

What is the type of datatype the async attribute optionally accepts?(a) Integer(b) String(c) Boolean(d) DecimalThe question was posed to me in class test.This interesting question is from Script Loading topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

Correct answer is (C) Boolean

For explanation I would say: The async attribute is a boolean attribute. When present, it specifies that the script will be EXECUTED asynchronously as soon as it is available. The async attribute OPTIONALLY accepts the boolean DATATYPE of default VALUE as true.

71.

Which is the next step after retrieving the content in chunks?(a) Paint DOM elements(b) Parse Content(c) Build DOM nodes in render tree(d) Layout positioning of DOM elementsThis question was addressed to me in unit test.I would like to ask this question from Page Render BottleNecks Optimization in division Invocation and Performance Navigation of JavaScript

Answer»

Right CHOICE is (b) Parse Content

Explanation: After retrieving the content in chunks, the contents will be PARSED. The Render ENGINE workflow contains:

Parse Content

Build DOM nodes in render tree

Layout positioning of DOM elements

Paint DOM elements.

72.

Which of the following gets converted to DOM elements by the rendering engine?(a) Tokens(b) Strings(c) Address(d) CharactersThis question was addressed to me in an interview.My doubt is from Page Render BottleNecks Optimization topic in section Invocation and Performance Navigation of JavaScript

Answer»

The correct OPTION is (a) Tokens

Explanation: The string returned by the network layer GETS tokenized into meaningful chunks. The rendering ENGINE then takes the tokens and converts them to DOM elements. There are five categories of tokens: 1) constants, 2) IDENTIFIERS, 3) operators, 4) separators, and 5) reserved words.

73.

Why are HTTP redirects significant?(a) TCP connection available(b) Complete roundtrip absent(c) Complete roundtrip present(d) TCP connection not availableThis question was addressed to me in an internship interview.The question is from Performance Navigation and Memory topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

Right option is (b) Complete ROUNDTRIP absent

The explanation is: HTTP redirects are significant because they cause a complete roundtrip for each redirect. The ORIGINAL REQUEST is RETURNED from the web server as either a 301 or a 302 with the path to the NEW location.

74.

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 favoritesI got this question by my college professor while I was bunking the class.This question is from Invocation of the Performance Object topic in division Invocation and Performance Navigation of JavaScript

Answer»

The CORRECT choice is (c) Navigation by moving back & forward through history

The BEST I can explain: 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.

75.

Which of the following is an attribute to the script object?(a) onclick(b) onload(c) onshow(d) onhoverI had been asked this question in my homework.This intriguing question originated from Lazy Loading in section Invocation and Performance Navigation of JavaScript

Answer»

Right choice is (B) onload

For EXPLANATION: The onload event OCCURS when an object has been LOADED. The onload event occurs when an object has been loaded.

76.

Which is the method used to add an event listener?(a) addEventListener()(b) addListener()(c) addEvent(Listener)(d) addListener(Event)I have been asked this question in exam.My question comes from Lazy Loading topic in division Invocation and Performance Navigation of JavaScript

Answer»

Right ANSWER is (a) ADDEVENTLISTENER()

The explanation: The addEventListener() method attaches an event handler to the specified element. The addEventListener() method is used to ADD an event LISTENER to the script.

77.

Which of the following constants hold the value 2?(a) TYPE_NAVIGATE(b) TYPE_RELOAD(c) TYPE_BACK_FORWARD(d) TYPE_RESERVEDI had been asked this question in homework.My doubt is from Performance Navigation and Memory in section Invocation and Performance Navigation of JavaScript

Answer»

Right answer is (c) TYPE_BACK_FORWARD

For explanation: TYPE_BACK_FORWARD performs NAVIGATION through a history traversal operation. TYPE_BACK_FORWARD: Has the value of 2, INDICATING that the PAGE was NAVIGATED to via the browser history, either USING the back or forward buttons or programmatically through the browser’s history object.

78.

How many read-only attributes are present in the navigator object?(a) 1(b) 2(c) 3(d) 4I have been asked this question in an interview for internship.Enquiry is from Performance Navigation and Memory topic in chapter Invocation and Performance Navigation of JavaScript

Answer»

The CORRECT option is (b) 2

The best I can EXPLAIN: The NAVIGATOR object contains information about the browser. There are a TOTAL of 2 read-only attributes present in the navigator object namely:

redirectCount

type.

79.

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/loadEventEndI have been asked this question in an interview for internship.The query is from Invocation of the Performance Object topic in portion Invocation and Performance Navigation of JavaScript

Answer»

Correct answer is (b) loadEventEnd-responseEnd

For explanation I would say: 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.

80.

Which of the following property is associated with the Response event?(a) responseStart(b) responseEnd(c) both responseStart and responseEnd(d) responsiveStartI have been asked this question in a national level competition.The doubt is from Invocation of the Performance Object in chapter Invocation and Performance Navigation of JavaScript

Answer»

The correct answer is (C) both responseStart and responseEnd

The explanation is: 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.