JavaScript Questions & Answers – JavaScript Benchmarking and Logging with perfLogger – II

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “JavaScript Benchmarking and Logging with perfLogger – II”.

1. What type of scope is present in JavaScript?
a) Lexical
b) Literal
c) Both Lexical and Literal
d) Local
View Answer

Answer: a
Explanation: Lexical scoping (sometimes known as static scoping) is a convention used with many programming languages that sets the scope (range of functionality) of a variable so that it may only be called (referenced) from within the block of code in which it is defined.

2. Which function is used to stop the time logging?
a) stopTimeLogging()
b) stop()
c) finish()
d) abort()
View Answer

Answer: a
Explanation: The function stopTimeLogging() is used to stop the time logging. The stopTimeLogging() stops the timing data for ad hoc, etc for referencing an uncached document.location.

3. The lexical scooping in JavaScript is based on which of the following?
a) Segments
b) Blocks
c) Functions
d) Entire code
View Answer

Answer: c
Explanation: Lexical scoping (sometimes known as static scoping) is a convention used with many programming languages that sets the scope (range of functionality) of a variable so that it may only be called (referenced) from within the block of code in which it is defined. JavaScript has lexical scoping based on functions but not blocks.
advertisement
advertisement

4. What is the return data type of the property accept that belongs to the Input element?
a) integer
b) string
c) boolean
d) float
View Answer

Answer: b
Explanation: The accept attribute is used to define the types of files that the control can select. When type is “file”, this property is a comma-separated list of MIME types that specify the types of files that may be selected. The strings “audio/*”, “video/*”, and “image/*” are also legal.

5. What is the purpose of the property width belonging to the ImageData element?
a) Number of data
b) Number of pixels
c) Number of pixels per row of data
d) Number of columns
View Answer

Answer: c
Explanation: Image data element indicates the intrinsic width of the image, in CSS pixels. The width property is used to retrieve or store the number of pixels per row of data.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. What is the purpose of the adoptNode() method?
a) Removes node
b) Makes it ready for insertion
c) Removes node and Makes it ready for insertion
d) Changes the node
View Answer

Answer: c
Explanation: This method removes the node from whatever document it is currently part of and changes its ownerDocument property to this document, making it ready for insertion into this document. The adoptNode() method adopts a node from another document. The adopted node can be of all node types.

7. What is the function of the method importNode()?
a) Copies without removing
b) Copies and removes
c) Only copies
d) Only removes
View Answer

Answer: a
Explanation: The importNode() method imports a node from another document. The imported node can be of all node types. The method importNode() copies a node from another document without removing it.
advertisement

8. How can you create a node for comment in JavaScript?
a) comment()
b) createComment()
c) comm()
d) create()
View Answer

Answer: b
Explanation: The comment node can be created using the method Comment createComment(string data). The createComment() method creates a Comment node with the specified text.

9. How can you dispatch a synthetic event object?
a) dispatchEvent()
b) dispatch()
c) dispatch(Event)
d) eventdispatch()
View Answer

Answer: a
Explanation: When you have created and initialized a synthetic event object, you can dispatch it using the dispatchEvent() method of EventTarget. The dispatchEvent method throws UNSPECIFIED_EVENT_TYPE_ERR if the event’s type was not specified by initializing the event before the method was called, or if the event’s type is null or an empty string.
advertisement

10. How do you specifically execute a command in JavaScript?
a) execcommand()
b) exec(command)
c) execCommand()
d) exec(command id)
View Answer

Answer: c
Explanation: The command can be executed using boolean execCommand(string commandId, [boolean showUI, [string value]]). The execCommand() method executes the specified command for the selected part of an editable section.

Sanfoundry Global Education & Learning Series – Javascript Programming.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.