Hello, in this JavaScript video I am going to show you exception handling, also known as error handling. So what is that? So let me let me just create a variable called var one according num one equals 91420. And let's do console dot log nine divided by zero, we know you can't do division by nine, and we just get in finity. So that's the result in some programming languages, it will literally crack depending on the language, you will get a different result. So maybe we want to handle this sort of error.
And we can do that pretty pretty easily. So all we need to do is do a toy block. So this is basically saying you're trying Some piece of code, so we're basically equal zero. Else. No, we perform elation. And I wasn't even using them to achieve the same result but we want to make sure you know if we have a problem yeah I would say fro zero damage at the end if you catch here and here we can console dot log Simply the close up okay, you will simply console log the error so far reload says you can't divide by zero damage.
So we didn't do this. So it's gone into here, let's say two nine divided by three, which is three, reload, we get the answer free. So that is error handling. There's one other block I want to show you. Where if we put if we put finally and the finally any code that's here will run regardless of whether or not an error is thrown or not or whether this is a flaw. So if you want code that is always run, and you put it here, console dot log, and then say, this is immortal.
Right, we got this code is immortal. But if I Zero instead. They still say this code is immortal because like I said, the finally will be one, regardless of whether an error or not, is room. So that's it for error handling. Thanks for watching. If you have any questions, feel free to drop me a message.
The GitHub link will be required and unusual. I look forward to the next awesome JavaScript video.