+ 2
try....catch
In java script I didn't understand try....catch. Can anyone explain it with examples?
7 Respuestas
+ 2
You may find answer in https://javascript.info/try-catch
+ 1
I said in javascript not java
+ 1
ok
+ 1
I couldn't understand the logic 😅 can you explain?
+ 1
As you know it gives an error when you try dividing number with 0. When this occurs, program brokes.
So if you type your code inside try block, program does not stop running, instead it handles the error and throws an exception.
For another example if you create string variable, and take an input, if user enters numerical value, program also brokes. Because,
string str != 227 (some numerical value)
To handle this too, you type your code inside try block, so your program does not stop running, but notifies user because something went wrong.
0
https://www.sololearn.com/Discuss/1523730/?ref=app
Please next time use search bar for your question before asking.
0
Its logic is same, does not matter which language you use.