Monday, February 4, 2013

JavaScript Quiz Part 2 (final part)

As you may know, JavaScript is the default scripting language of the browser. In addition, much test automation is also written in JavaScript. If you have not attempted the Part 1 of this Quiz, do that first. Then attempt this part of the quiz to find out how well you know JavaScript. If you can answer 8 or more questions correctly in each part, then you are a JavaScript expert :)

1. Where can JavaScript code be placed within an HTML document?
Only in the HEAD section
Only in the BODY section
In the HEAD section and/or in the BODY section
In the HEAD and/or in BODY section but functions must be put in the HEAD section
2. What does the expression Math.max(Math.round(Math.random()),0) return?
Either 0 or 1
Always 0
Always 1
A floating number between 0 and 1
3. Which of the following date object methods has a 1-based return value (i.e. it returns a number between 1 and something)?
4. Which function returns a part of the array without affecting the original array?
5. How can parameters be accessed within the function body for a function defined without parameters and invoked with parameters?
Using the arguments array
Using the arguments object
This is not possible.
This is only possible when the function is overloaded (with no parameters and with same number of parameters passed in the function call).
6. Which function can be invoked on an existing node to add a child node?
7. What is the correct syntax for opening a new window or tab in the browser?
This is not possible in JavaScript.
8. Which data should be set in document.cookie to create a cookie?
cookie name
cookie value
expiration date
all of the above
9. The try statement requires at least which of the following?
a throw statement
a catch statement
a finally statement
either a catch statement or a finally statement
10. Which JavaScript object represents the browser?
document object
screen object
window object
navigator object
Score is 0/ 10.

No comments:

Post a Comment