0
Error handling in js please explain me this code
try { null.console console.log("We are inside try block"); functionHarry(); } catch(error) { console.log(error) console.log("Are you okay?"); console.log(error.name); console.log(error.message); } finally { console.log("Finally we will run this") }
3 Answers
+ 2
If there is an error during the execution of the code in the block try, we stop the code of the try and we execute the code of the block catch.
Whether there is an error or not, we finish by executing the code finally.
1/ first Line of try block make error
2/ execute catch block
3/ execute finally block
If you don't use try / catch, program should crash and stop.
0
null.console what is this
0
Yes, null.console make an error, so code in try block stop and catch block running