Exam4Training

How can the developer change the code to ensure this behavior?

A developer wrote the following code:

01 let X = object.value;

02

03 try {

4 handleObjectValue(X);

5 } catch (error) {

6 handleError(error);

7 }

The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs.

How can the developer change the code to ensure this behavior?
A . 03 try{
4 handleObjectValue(x);
5 } catch(error){
6 handleError(error);
7 } then {
8 getNextValue();
9 }
B . 03 try{
4 handleObjectValue(x);
5 } catch(error){
6 handleError(error);
7 } finally {
8 getNextValue();
10 }
C . 03 try{
4 handleObjectValue(x);
5 } catch(error){
6 handleError(error);
07 }
8 getNextValue();
D . 03 try {
4 handleObjectValue(x)
5 ……………………

Answer: D

Exit mobile version