JavaScript Language | 10 Minute‐Test 6


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.

Which attribute is used to specify that the script is executed when the page has finished parsing ( only for external scripts )

A.
parse
B.
async
C.
defer
D.
type

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

In order to load a page, the browser must parse the contents of all script tags, which adds additional time to the page load. By minimizing the amount of JavaScript needed to render the page, and deferring parsing of unneeded JavaScript until it needs to be executed, you can reduce the initial load time of your page.

2.

Which of the following is not considered as an error in JavaScript?

A.
Syntax error
B.
Missing of semicolons
C.
Division by zero
D.
All of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Division by zero is not an error in JavaScript: it simply returns infinity or negative infinity. There is one exception, however: zero divided by zero does not have a welldefined value, and the result of this operation is the special not-a-number value, printed as NaN.

3.

What kind of an expression is “new Point(2,3)”?

A.
Primary Expression
B.
Object Creation Expression
C.
Invocation Expression
D.
Constructor Calling Expression

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

An object creation expression creates a new object and invokes a function (called a constructor) to initialize the properties of that object. Object creation expressions are like invocation expressions except that they are prefixed with the keyword new.

4.

When an empty statement is encountered, a JavaScript interpreter

A.
Ignores the statement
B.
Prompts to complete the statement
C.
Throws an error
D.
Throws an exception

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The JavaScript interpreter takes no action when it executes an empty statement. The empty statement is occasionally useful when you want to create a loop that has an empty body.

5.

What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?

A.
The property will be stored in a cache
B.
The loop will not run
C.
That property will not be enumerated
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

If the body of a for/in loop deletes a property that has not yet been enumerated, that property will not be enumerated. If the body of the loop defines new properties on the object, those properties will generally not be enumerated.

6.

To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the

A.
isPrototypeOf() method
B.
equals() method
C.
=== operator
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the isPrototype() method. To find out if p is the prototype of o write p.isPrototypeOf(o).

7.

Consider the following code snippet :

var a = [1,2,3,4,5];

a.slice(0,3);


What is the possible output for the above code snippet ?

A.
Returns [1,2,3]
B.
Returns [4,5]
C.
Returns [1,2,3,4]
D.
Returns [1,2,3,4,5]

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

8.

A function with no return value is called

A.
Procedures
B.
Method
C.
Static function
D.
Dynamic function

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Functions with no return value are sometimes called procedures.

9.

If you have a function f and an object o, you can define a method named m of o with

A.
o.m=m.f;
B.
o.m=f;
C.
o=f.m;
D.
o=f;

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

method is nothing more than a JavaScript function that is stored in a property of an object. If you have a function f and an object o, you can define a method named m of o with the following line:
o.m = f;

10.

Consider the following code snippet :

var scope = "global scope";

function checkscope() {

var scope = "local scope";

function f()

{

     return scope;

}

return f;


What is the function of the above code snippet?

A.
Returns value null
B.
Returns exception
C.
Returns the value in scope
D.
None of the mentioned
Submit your test now to view the Results and Statistics with answer explanation.