JavaScript Questions & Answers – JavaScript in Web Browsers – I

«
»

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “JavaScript in Web Browsers – I”.

1. The word “document” mainly refers to ______________
a) Dynamic Information
b) Static Information
c) Both Dynamic and Static Information
d) Temporary information
View Answer

Answer: b
Explanation: Some pages present static information and can be called documents. The document is a keyword which is used in selecting any particular element in the document.
advertisement

2. Which object is the main entry point to all client-side JavaScript features and APIs?
a) Standard
b) Location
c) Window
d) Position
View Answer

Answer: c
Explanation: The Window object is the main entry point to all client-side JavaScript features and APIs. It represents a web browser window or frame, and you can refer to it with the identifier window.

3. Which identifier is used to represent a web browser window or frame?
a) frames
b) window
c) location
d) frame
View Answer

Answer: b
Explanation: The window object represents a web browser window or frame, and you can refer to it with the identifier window. Global variables are properties of the window object and Global functions are methods of the window object.
advertisement
advertisement

4. Which property in the Window object is used to refer to a Location object?
a) position
b) area
c) window
d) location
View Answer

Answer: d
Explanation: The Window object defines properties like location, which refers to a Location object that specifies the URL currently displayed in the window and allows a script to load a new URL into the window. The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.

5. Which Window object method is used to display a message in a dialog box?
a) alert()
b) prompt()
c) message()
d) console.log
View Answer

Answer: a
Explanation: The Window object defines methods like alert(), which displays a message in a dialog box. A prompt message can be displayed on the screen using alert().
advertisement

6. The setTimeout() method is used to _______________
a) Make the event sleep
b) Register a function to be invoked after a certain time
c) Invoke an event after a certain time
d) Time for iteration
View Answer

Answer: b
Explanation: The setTimeout(), which registers a function to be invoked after a specified amount of time. The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.

7. Which of the following is a global object?
a) Register
b) Location
c) Window
d) Position
View Answer

Answer: c
Explanation: In client-side JavaScript, the Window object is also the global object. This means that the Window object is at the top of the scope chain and that its properties and methods are effectively global variables and global functions.
advertisement

8. When will the window property come into play?
a) Representation convenience
b) Use as an extension of other objects
c) Use objects in the Window object
d) Refer to window object itself
View Answer

Answer: d
Explanation: The Window object has a property named window that always refers to itself. You can use this property if you need to refer to the window object itself.

9. Which is the property that represents the content displayed in the window?
a) document
b) content
c) window
d) frame
View Answer

Answer: a
Explanation: One of the most important properties of the Window object is document: it refers to a Document object that represents the content displayed in the window.
advertisement

10. How to pick a document element based on the value of its id attribute?
a) getElementsbyId()
b) getElementbyId()
c) both getElementsbyId() and getElementbyId()
d) getElement
View Answer

Answer: b
Explanation: The Document object has important methods such as getElementById(), which returns a single document element (representing an open/close pair of HTML tags and all of the content between them) based on the value of its id attribute. Using this property different operation can be performed on the selected element.

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