// Error = An Object that is created to represent a problem that occurs // Occur often with user input or establishing a connection // try { } = Encloses code that might potentially cause an error // catch { } = Catch and handle any thrown Errors from try { } // finally { } = (optional) Always executes. Used mostly for clean up // ex. close files, close connections, release resources try{ const dividend = Number(window.prompt("Enter a dividend: ")); const divisor = Number(window.prompt("Enter a divisor: ")); if(divisor == 0){ throw new Error("You can't divide by zero!"); } if(isNaN(dividend) || isNaN(divisor)){ throw new Error("Values must be a number"); } const result = dividend / divisor; console.log(result); } catch(error){ console.error(error); } finally{ console.log("This always executes"); } console.log("You have reached the end!");
@yeeter420Ай бұрын
One of the best channels for learning code. Thank you❤
@justmakeitviral4733 Жыл бұрын
I love these short videos....it's good for revision
@slimak1278Ай бұрын
Thanks, we learned quite a bit about JavaScript in school, but we didn't learn how to handle errors, so again, thank you.
@xmorlanzz Жыл бұрын
repetition is the mother of learning, fellow programmers!
@fadelsaad662328 күн бұрын
Dude thank you, It seemed much harder to me but after watching the vid it makes so much sense
@Sijo211 ай бұрын
Thank you for this tutorial video. I really helped my understanding
@hunin27 Жыл бұрын
i always did lots of if statements to handle errors and i thought it was the best way lol
@teoanilacar9 ай бұрын
This guy is awesome!
@jahazielvazquez726411 ай бұрын
Clear as day! Thank you good sir
@dev_ression Жыл бұрын
nicely explained bro, thank you!
@popsbeats_1004 ай бұрын
Beautiful👌🏿
@ProgrammingJourney-hk6wfАй бұрын
Thank you bro ❤. Very well explained!
@subinkv684911 ай бұрын
Great content..
@EnzoJasonCotia5 ай бұрын
Thank you 😢
@s.a.r.a.015 ай бұрын
thank you for this
@dimitro.cardellini8 ай бұрын
But why not just check if result is Infinity or NaN after we performed the division? Actually, the fact that JS doesn't fail on division by zero is an intentional feature of JS.