JavaScript Language | 10 Minute‐Test 8


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

JavaScript can be written

A.
directly into JS file and included into HTML
B.
directly on the server page
C.
directly into HTML pages
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

2.

The snippet that has to be used to check if “a” is not equal to “null” is

A.
if(a!=null)
B.
if (!a)
C.
if(a!null)
D.
if(a!==null)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The not-equal operator !== compares o to null and evaluates to either true or false.

3.

Among the following, which one is a ternary operator?

A.
+
B.
:
C.
D.
?:

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

JavaScript supports one ternary operator, the conditional operator ?:, which combines three expressions into a single expression.

4.

Consider the following statements

switch(expression)

{

    statements

}


In the above switch syntax, the expression is compared with the case labels using which of the following operator(s) ?

A.
==
B.
equals
C.
equal
D.
===

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

When a switch executes, it computes the value of expression and then looks for a case label whose expression evaluates to the same value (where sameness is determined by the === operator).

5.

Consider the following code snippet

while (a != 0)

{

   if (a == 1)

       continue;

   else

       a++;

}


What will be the role of the continue keyword in the above code snippet?

A.
The continue keyword restarts the loop
B.
The continue keyword skips the next iteration
C.
The continue keyword skips the rest of the statements in that iteration
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Instead of exiting a loop like the break keyword, the continue keyword moves to the next iteration from the place encountered.

6.

The purpose of extensible attribute is to

A.
make all of the own properties of that object nonconfigurable
B.
to configure and bring a writable property
C.
“lock down” objects into a known state and prevent outside tampering
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The purpose of the extensible attribute is to be able to “lock down” objects into a known state and prevent outside tampering.

7.

The primary purpose of the array map() function is that it

A.
maps the elements of another array into itself
B.
passes each element of the array and returns the necessary mapped elements
C.
passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function.
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The map() method passes each element of the array on which it is invoked to the functionyou specify, and returns an array containing the values returned by that function.

8.

Which of the following is the correct code for invoking a function without this keyword at all, and also too determine whether the strict mode is in effect?

A.
var strict = (function { return this; });
B.
mode strict = (function() { return !this; }());
C.
var strict = (function() { return !this; }());
D.
mode strict = (function { });

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The above code defines and invokes a function to determine if we’re in strict mode.

9.

What is the difference between the two lines given below ?

!!(obj1 && obj2);
(obj1 && obj2);

A.
Both the lines result in a boolean value “True”
B.
Both the lines result in a boolean value “False”
C.
Both the lines checks just for the existence of the object alone
D.
The first line results in a real boolean value whereas the second line merely checks for the existence of the objects

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

10.

What is the opposite approach to the lexical scoping?

A.
Literal scoping
B.
Static scoping
C.
Dynamic scoping
D.
Generic scoping
Submit your test now to view the Results and Statistics with answer explanation.