JavaScript Questions & Answers – Script Loading – II

«
»

This set of JavaScript Question Bank focuses on “Script Loading – II”.

1. 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 fragment
View Answer

Answer: c
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.
advertisement

2. What is the default value of the asyc attribute?
a) 0
b) 1
c) False
d) True
View Answer

Answer: d
Explanation: 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 a boolean value and by default holds the value true.

3. What is the method to create a data frame?
a) frame(data)
b) frameData()
c) data.frame()
d) frame.Data()
View Answer

Answer: c
Explanation: A Data frame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns.
advertisement
advertisement

4. What is the purpose of creating a data frame?
a) Hold the page render time
b) Hold the load time
c) Hold the page render time & load time
d) Hold the reload time
View Answer

Answer: c
Explanation: A Data frame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns. You can create a data frame to hold the mean page render times for each test URL, and a data frame to hold the mean load time for each test URL.

5. Which of the following navigator object properties is the same in both Netscape and IE?
a) navigator.appCodeName
b) navigator.appName
c) navigator.appVersion
d) appcode.navigator()
View Answer

Answer: a
Explanation: The property navigator.appCodeName is the same in both Netscape and IE. The appCodeName property returns the code name of the browser.
advertisement

6. Which best explains getSelection()?
a) Returns the VALUE of a selected OPTION
b) Returns document.URL of the window in focus
c) Returns the value of cursor-selected text
d) Returns the VALUE of a checked radio input
View Answer

Answer: c
Explanation: The Window.getSelection() method returns a Selection object representing the range of text selected by the user or the current position of the caret. The getSelection() method returns the value of the cursor-selected text.

7. Which of the following are client-side JavaScript object?
a) Database
b) Cursor
c) Client
d) FileUpLoad
View Answer

Answer: d
Explanation: The Input FileUpload object represents an HTML <input> element with type=”file”. The FileUpLoad is a client-side JavaScript object.
advertisement

8. What is the purpose of the method localeCompare()?
a) If the reference string comes before or after another string
b) If the reference string is validated
c) If the string is a reference string
d) If the reference string comes first
View Answer

Answer: a
Explanation: The localeCompare() method compares two strings in the current locale. The locale is based on the language settings of the browser. The method localeCompare() returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.

9. When the “end” event fires on EOF when no more data will arrive, which function is called?
a) s.on(“data”,f);
b) s.on(“end”,f);
c) s.on(“error”,f);
d) s.on(“default”,f);
View Answer

Answer: b
Explanation: In computing, end-of-file (commonly abbreviated EOF) is a condition in a computer operating system where no more data can be read from a data source. The above code snippet gets “end” event fired on EOF when no more data will arrive.
advertisement

10. To define each of the set classes as a property of the sets object (namespace) for the module, the statement is ___________
a) sets = sets.AbstractEnumerableSet.extend();
b) sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);
c) sets.SingletonSet = sets.extend(…);
d) sets = sets.extend(…);
View Answer

Answer: b
Explanation: The Set object lets you store unique values of any type, whether primitive values or object references. The sets object is the namespace for the module, and we define each of the set classes as a property of this object.

Sanfoundry Global Education & Learning Series – Javascript Programming.

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!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter