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
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
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
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.
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
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
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.
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
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
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.
8. How can you create a node for comment in JavaScript?
a) comment()
b) createComment()
c) comm()
d) create()
View Answer
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
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.
10. How do you specifically execute a command in JavaScript?
a) execcommand()
b) exec(command)
c) execCommand()
d) exec(command id)
View Answer
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]
- Apply for Computer Science Internship
- Check Programming Books
- Practice Programming MCQs
- Practice Information Science MCQs
- Check JavaScript Books