This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Client-Side JavaScript”.
1. The main purpose of JavaScript in web browser is to ___________
a) Creating animations and other visual effects
b) User Interface
c) Visual effects
d) User experience
View Answer
Explanation: JavaScript can help to facilitate that experience, for example by:
- Creating animations and other visual effects to subtly guide a user and help with page navigation
- Sorting the columns of a table to make it easier for a user to find what she needs
2. A JavaScript program can traverse and manipulate document content through __________
a) Element Object
b) Document Object
c) Both Element and Document Object
d) Data object
View Answer
Explanation: A JavaScript program can traverse and manipulate document content through the Document object and the Element objects it contains. It can alter the presentation of that content by scripting CSS styles and classes. The Element object represents an HTML element, like P, DIV, A, TABLE, or any other HTML element.
3. The behaviour of the document elements can be defined by __________
a) Using document object
b) Registering appropriate event handlers
c) Using element object
d) Using data element
View Answer
Explanation: The JavaScript program can define the behavior of document elements by registering appropriate event handlers. A JavaScript program can traverse and manipulate document content through the Document object and the Element objects it contains.
4. The service(s) that enables networking through scripted HTTP requests is __________
a) XMLHttpResponse
b) XMLRequest
c) XMLHttpRequest
d) XMLHttps
View Answer
Explanation: The best known advanced services is the XMLHttpRequest object, which enables networking through scripted HTTP requests. The XMLHttpRequest object can be used to request data from a web server.
5. The HTML5 specification does not includes __________
a) Data storage
b) Graphics APIs
c) Other APIs for web apps
d) Networking
View Answer
Explanation: The HTML5 specification (which, at the time of this writing, is still in draft form) and related specifications are defining a number of other important APIs for web apps. These include data storage and graphics APIs.The data storage api can store data locally within the user’s browser.
6. Which of the following is not an advanced services?
a) Data storage
b) Networking
c) XMLHttpRequest object
d) Graphics APIs
View Answer
Explanation: Data storage is used to store data locally on user’s computer and networking is used for connecting between different platforms.
7. JavaScript code between a pair of “script” tags are called __________
a) Non-inline
b) External
c) Referenced
d) Inline
View Answer
Explanation: The <script> tag is used to define a client-side script (JavaScript). The <script> element either contains scripting statements, or it points to an external script file through the src attribute. Inline code are those that are written between a pair of “script” tags.
8. Client-side JavaScript code is embedded within HTML documents in __________
a) A URL that uses the special javascript:encoding
b) A URL that uses the special javascript:stack
c) A URL that uses the special javascript:protocol
d) A URL that uses the special javascript:code
View Answer
Explanation: The Client-side JavaScript code is embedded within HTML documents in four ways :
- Inline, between a pair of “script” tags
- From an external file specified by the src attribute of a “script” tag
- In an HTML event handler attribute, such as onclick or onmouseover
- In a URL that uses the special javascript: protocol.
9. What is the programming philosophy that argues that content and behaviour should as much as possible be kept separate?
a) Unobtrusive JavaScript
b) Obtrusive JavaScript
c) Inherited JavaScript
d) Modular JavaScript
View Answer
Explanation: A programming philosophy known as unobtrusive JavaScript argues that content (HTML) and behavior (JavaScript code) should as much as possible be kept separate. According to this programming philosophy, JavaScript is best embedded in HTML documents using “script” elements with src attributes.
10. Which of the following communicates with server-side CGI scripts through HTML form submissions and can be written without the use of JavaScript?
a) Static Web Pages
b) Interactive Web Pages
c) Conditional Web Pages
d) All web pages
View Answer
Explanation: An interactive web page can dynamically vary its content based on user preferences. Interactive web pages that communicate with server-side CGI scripts through HTML form submissions were the original “web application” and can be written without the use of JavaScript.
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]
- Practice Programming MCQs
- Apply for Computer Science Internship
- Practice Information Science MCQs
- Check Programming Books
- Check JavaScript Books