PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an application that uses a third-party JavaScript library named doWork().
The library occasionally throws an “object is null or undefined” error with an error code of -2146823281.
The application must:
Extract and handle the exceptions thrown by doWork()
Continue normal program execution if other exceptions occur
You need to implement the requirements.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
if( doWork() == -2146823281) {

}

B.
if( doWork() == “object is null or undefined”) {

}

C.
try {
doWork();
} catch(e) {
if(e.number == -2146823281)

}

D.
try {
doWork();
} catch(e) {
if(e.message == -2146823281)

}

2 Comments on “Which code segment should you use?

    1. David says:

      J, I agree, nevertheless the questions says:
      “The library occasionally throws an ‘object is null or undefined’ error with an error code of -2146823281.”
      In my view, this means that this error would have “object is null or undefined” as message and as it talks about ‘code’, I would say “-2146823281” as number
      Therefore in this context, regardless of the browser compatibility, I would say C is the right answer because I can’t see that code being saved anywhere else in the error object.




      0



      0

Leave a Reply