Sunday, January 20, 2013

JavaScript Quiz Part 1

As you know, JavaScript is a very popular programming language used to create interactive websites. Also, much test automation is also written in JavaScript. Attempt this quiz to find out how well you know JavaScript and see how many questions you are able to answer correctly.

1. In javascript, what happens when two functions call each other recursively?
Javascript error
The two functions keep calling each other endlessly.
The recursive calls stop after some time.
The browser displays an alert asking the user to decide if the recursive calls should continue or not.

2. What is the result of applying an arithmetic operator on a string?
Javascript error
The program execution stops at the error.

3. How do you reduce the time it takes a javascript switch statement to execute?
Write all possible cases for the expression.
Write a break statement after every case.
Include a default.
Change the value of the expression within every case.

4. What is the difference between == and === operators in javascript?
There is no === operator in javascript.
There is no difference between the two.
== compares the value but === assigns first and then compares the value so it always returns true.
== compares only the value but === compares both the value and the datatype.

5. What happens when a javascript function is called with extra parameters? For example, the function is defined with 2 parameters but is invoked with 3 parameters.
All the extra parameters at the end are ignored.
All the parameters are turned undefined.
Javascript error
All the extra parameters at the beginning are ignored.

6. Which javascript loop runs at least once?
for loop
for in loop
while loop
do while loop

7. What is the result of running the following loop?
var i=1;
for(;;) {
if (i>5) {break;}
Javascript error in the for statement

8. In javascript, what is the preferred way of creating just one instance of a user-defined object?
createObject function
Object constructor function
Object initializer
You cannot create user-defined objects in javascript

9. The concat method does which of the following tasks in javascript?
Creates a new array joining two or more existing arrays
Appends one array to another array
Appends one or more arrays to an array
Concatenates all the strings in the array elements

10. In javascript, the elements of an associative array can be referred by their number index. True or false?
Please now go to the Part 2 of this JavaScript Quiz by clicking here.

No comments:

Post a Comment