Which code segment should you insert at line 05?

You are developing an application that uses a JavaScript library. The library contains the
following functions.

The application uses the following code. (Line numbers are included for reference only.)

The library may throw many types of exceptions. The exceptions are grouped by category.
You need to catch and identify the exceptions by group.
Which code segment should you insert at line 05?

You are developing an application that uses a JavaScript library. The library contains the
following functions.

The application uses the following code. (Line numbers are included for reference only.)

The library may throw many types of exceptions. The exceptions are grouped by category.
You need to catch and identify the exceptions by group.
Which code segment should you insert at line 05?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Will

Will

Note: A is incorrect because typeof e returns “object”.
Thus, B is correct because you have to use e instanceof ObjectName to verify that it is an instance of the object.

brkyctn

brkyctn

Explanation/Reference:
instanceof
The instanceof operator tests whether an object has in its prototype chain the prototype property of a
constructor.
The instanceof operator tests presence of constructor.prototype in object prototype chain.
Example::
// defining constructors
function C(){}
function D(){}
var o = new C();
// true, because: Object.getPrototypeOf(o) === C.prototype
o instanceof C;
// false, because D.prototype is nowhere in o’s prototype chain
o instanceof D;
Reference: instanceof